Hello,
I would like to insert a binary data into the table.
I have the following problems:
1) How can I select binary data from table?
(I have try execute select statement in the SQL plus, but
it return error)
2) I have used the oracle JDBC thin client driver to insert a
binary data into table, the code as follow:
=================================================================
byte [] testData = "this is some test
data".getBytes();
Class.forName("oracle.jdbc.driver.OracleDriver");
conn = DriverManager.getConnection
("jdbc:oracle:thin:@(DESCRIPTION =(ADDRESS_LIST =(ADDRESS =
(PROTOCOL = TCP)(HOST = 192.168.0.xx)(PORT = 1521)) )
(CONNECT_DATA = (SERVICE_NAME = xxx) ) )","xxx","xxx");
BLOB b1 = new BLOB((OracleConnection)
conn,testData);
PreparedStatement stmt = conn.prepareStatement
("insert into testdata (id,data) values (?,?)");
stmt.setString(1,"1");
stmt.setBlob(2, b1);
stmt.executeQuery(); // throw the exception at
that line
stmt.close();
conn.close();
=================================================================
I have got the following exception:
=================================================================
java.sql.SQLException: ORA-22990: LOB locators cannot span
transactions
at oracle.jdbc.dbaccess.DBError.throwSqlException
(DBError.java:114)
at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:208)
at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:542)
at oracle.jdbc.ttc7.TTC7Protocol.doOall7
(TTC7Protocol.java:1311)
at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteFetch
(TTC7Protocol.java:738)
at oracle.jdbc.driver.OracleStatement.executeNonQuery
(OracleStatement.java:1313)
at oracle.jdbc.driver.OracleStatement.doExecuteOther
(OracleStatement.java:1232)
at oracle.jdbc.driver.OracleStatement.doExecuteWithBatch
(OracleStatement.java:1353)
at oracle.jdbc.driver.OracleStatement.doExecute
(OracleStatement.java:1760)
at
oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout
(OracleStatement.java:1805)
at
oracle.jdbc.driver.OraclePreparedStatement.executeUpdate
(OraclePreparedStatement.java:322)
at
oracle.jdbc.driver.OraclePreparedStatement.executeQuery
(OraclePreparedStatement.java:280)
at com.kit.db.InstanceDB2.main(InstanceDB2.java:54)
================================================================
What wrong of my code?
3) Could you mind send me some example about the insert and
select of BLOB data type?
Thank you very much