I'm trying to insert a blob to an Oracle database and JDBIv3.
jdbi.useHandle(handle -> {
Connection connection = handle.getConnection();
Blob fileContents = connection.createBlob();
fileContents.setBytes(1, Files.readAllBytes(path));
handle.createUpdate("insert into <tableName> (id, input_data) select a_seq.nextval, :fileContents from dual")
.define("tableName", tableName)
.bind("fileContents", fileContents)
.execute();
});
I need to get the connection to create the Blob which is then bound to the connection on which it was created.
Is there a way to use SQLObjects with blobs.
I did try passing a by byte[] instead of a blob but this gave me the following:
org.jdbi.v3.core.statement.UnableToExecuteStatementException: java.sql.SQLException: ORA-01461: can bind a LONG value only for insert into a LONG column