Pessoal, estou tentando persistir uma imagem em um campo OrdImage da oracle mas é gerado a seguinte mensagem:
No banco de dados tenho uma tabela chamada:
ID_DOCUMENTOIMAGEM que tem os seguintes campos:
O erro acontece no meu método insertImage na linha 32
OraclePreparedStatement stmt2 = (OraclePreparedStatement) con.prepareStatement(rowSelectSQL);
[code] public boolean insertImage(int fk_document, File imagem, Connection con) throws SQLException, IOException, ServletException {
if (con == null) {
con = Pilha.getConexao(); // Estabelce conexao
}
Statement stmt = null;
InputStream streamImage = new FileInputStream(imagem);
PreparedStatement ps = null;
OrdImage imageProxy = null;
OraclePreparedStatement opstmt = null;
OracleResultSet rset = null;
int resultado = 0;
int id = 0;
try{
stmt = con.createStatement();
id = retornaProximoIdDocumentoImagem(con);
String rowInsertSQL = "insert into VEP_CNJ_TB_DOCUMENTO_IMAGEM (ID_DOCUMENTOIMAGEM, FK_DOCUMENTO, IMAGEM) values (" + id + ", " + fk_document + ", ordsys.ordimage.init ())";
stmt.execute(rowInsertSQL);
} catch (Exception e) {
e.printStackTrace();
}finally{
//alguma operação como fechar conexão...
}
try{
con.setAutoCommit(false);
String rowSelectSQL = "select IMAGEM from VEP_CNJ_TB_DOCUMENTO_IMAGEM where ID_DOCUMENTOIMAGEM = " + id + " for update";
OraclePreparedStatement stmt2 = (OraclePreparedStatement) con.prepareStatement(rowSelectSQL);
rset = (OracleResultSet) stmt2.executeQuery();
rset.next();
imageProxy = (OrdImage)rset.getORAData("IMAGEM", OrdImage.getORADataFactory());
rset.close();
imageProxy.loadDataFromInputStream(streamImage);
imageProxy.setProperties();
} catch (SQLException s) {
s.printStackTrace();
}catch (Exception e) {
e.printStackTrace();
}finally{
rset.close();
}
try{
String updateSQL = "update VEP_CNJ_TB_DOCUMENTO_IMAGEM set IMAGEM = ? where ID_DOCUMENTOIMAGEM = ?";
opstmt = (OraclePreparedStatement)con.prepareStatement(updateSQL);
opstmt.setORAData(1, imageProxy);
opstmt.setInt(2, id);
}finally{
opstmt.execute();
opstmt.close();
}
if (ps != null)
ps.close();
return resultado > 0;
}[/code]
Alguem pode me ajudar?
Grato!