Gravar imagem no Postgre 8

Olá pessoal,

Estou sofrendo com esse postgre. Estou fazendo uma aplicação para cadastrar impressões digitais e validar na tela de login, que no caso seria a própria digital do cara. Eu tenho todos os exemplos para fazer funcionar a aplicação mas o meu problema está no Postgre, na versão 7.1, fazendo o rotina a seguir, ele dava certo.

try { File file = new File("d:/www/leitor_digital/teste.jpg"); FileInputStream fis = new FileInputStream(file); PreparedStatement ps = con.conn.prepareStatement("INSERT INTO saude.cadastro_digital VALUES (?)"); ps.setBinaryStream(1, fis, file.length()); ps.executeUpdate(); ps.close(); fis.close(); JOptionPane.showMessageDialog(this,"Cadastro efetuado com sucesso!","Cadastro!",JOptionPane.INFORMATION_MESSAGE); } catch (SQLException e) { e.printStackTrace(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); }

Agora na versão 8, não é a mesma coisa, utiliza-se setBytes. Tentei fazer a adaptação:

PreparedStatement stm = con.conn.prepareStatement("INSERT INTO saude.tabela_teste VALUES(?)"); ByteArrayInputStream input = new ByteArrayInputStream(util.template.getData()); stm.setBytes(1, util.template.getData()); stm.executeUpdate();

E retorna o seguinte erro:

[code]FastPath call returned ERROR: invalid large-object descriptor: 0

at org.postgresql.fastpath.Fastpath.fastpath(Fastpath.java:141)
at org.postgresql.fastpath.Fastpath.fastpath(Fastpath.java:191)
at org.postgresql.largeobject.LargeObject.write(LargeObject.java:173)
at org.postgresql.jdbc2.PreparedStatement.setBytes(PreparedStatement.java:300)
at cadastro_digital.btCadastrarActionPerformed(cadastro_digital.java:197)
at cadastro_digital.access$000(cadastro_digital.java:21)
at cadastro_digital$1.actionPerformed(cadastro_digital.java:113)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source) [/code]

Alguém já cadastrou fotos ou usou esse esquema de bytestream no Postgre 8? Parece que só o Postgre tem esse problema, pois até o HSQLDB funciona :roll:

Obrigado.