Seguinte:
Blob b = rs.getBlob("ARQUIVO");
BufferedOutputStream os;
File file = new File(path + "\\" + rs.getString("NOME"));
System.out.println(path + "\\" + rs.getString("NOME"));
os = new BufferedOutputStream(new FileOutputStream(file));
System.out.println(b.length() + " é o comprimento");
os.write(b.getBytes(0, (int) b.length()), 0, (int) b.length());
os.flush();
os.close();
O que tem d errado neste código? ele está lançando a segunte exceção:
18944 é o comprimento
java.sql.SQLException: Position 'pos' can not be < 1
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1075)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:989)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:984)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:929)
at com.mysql.jdbc.Blob.getBytes(Blob.java:136)
at Tab$1.mouseClicked(Tab.java:154)
at java.awt.AWTEventMulticaster.mouseClicked(AWTEventMulticaster.java:253)
at java.awt.Component.processMouseEvent(Component.java:6266)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3267)
at java.awt.Component.processEvent(Component.java:6028)
at java.awt.Container.processEvent(Container.java:2041)
at java.awt.Component.dispatchEventImpl(Component.java:4630)
at java.awt.Container.dispatchEventImpl(Container.java:2099)
at java.awt.Component.dispatchEvent(Component.java:4460)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4574)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4247)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4168)
at java.awt.Container.dispatchEventImpl(Container.java:2085)
at java.awt.Window.dispatchEventImpl(Window.java:2478)
at java.awt.Component.dispatchEvent(Component.java:4460)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
Achei uma ajuda na pág do apache, dis que lança essa exceção qdo
"São lançadas exceções se pos < 1, se pos for maior que o comprimento, ou se length <= 0"
length tá normal, com podem ver acima da exceção. Não manjo essa parte de binario, se alguem puder ajudar, fico agradecido!
valeu