I'm having problems when trying to insert in my ORACLE ddbb using PreparedStatement. Its seems to be related to the Blob data type than I'm handling. In this link changing type the solution was to change the type of the data from Blob to String but this is not what I'm looking for. I need to insert a Blob in my table.
Here is my code:
public void insert( Connection conn , String id, String imageName, byte[] image ) throws Exception {
PreparedStatement ps = null;
Blob img = conn.createBlob();
img.setBytes(1, image);
try {
String sql = "INSERT INTO MY_OWNER.IMAGE_TABLE "
+ "(ID, IMAGE_NAME, BLOB_IMAGE) "
+ "VALUES (?, ?, ?) ";
ps = conn.prepareStatement(sql);
ps.setString(1, id);
ps.setString(2, imageName);
ps.setBlob(3, img);
ps.executeUpdate();
conn.commit();
} catch ( Exception e ) {
conn.rollback();
throw new Exception ( e );
} finally {
if ( ps != null ) {
ps.close();
}
if ( conn != null ) {
conn.close();
}
}
}
I'm sure to have privileges and also sure about the syntax. Like I said, I believe the Blob it's bothering.
Here is the error:
java.lang.Exception: java.sql.SQLSyntaxErrorException: ORA-00942: table or view does not exist
Caused by: java.sql.SQLSyntaxErrorException: ORA-00942: table or view does not exist
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:440)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:396)
at oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:837)
at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:445)
at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:191)
at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:523)
at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:207)
at oracle.jdbc.driver.T4CPreparedStatement.executeForRows(T4CPreparedStatement.java:1010)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1315)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3576)
at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:3657)
at oracle.jdbc.driver.OraclePreparedStatementWrapper.executeUpdate(OraclePreparedStatementWrapper.java:1350)
Do you have any idea what is all about?
Thanks!!!