By submitting your email address, you agree to receive emails regarding relevant topic offers from TechTarget and its partners. You can withdraw your consent at any time. Contact TechTarget at 275 Grove Street, Newton, MA.
Here's the code:
myPreparedStatement = myConnection.prepareStatement ("INSERT INTO AMC_NEWB_XML VALUES (?, ?, ?, ?)"); myPreparedStatement.setString(1, mySessionId); myPreparedStatement.setInt(2, 1); Calendar myCal = Calendar.getInstance(); java.util.Date myUtilDate = myCal.getTime(); java.sql.Date mySqlDate = new java.sql.Date(myUtilDate.getTime()); myPreparedStatement.setDate(3, mySqlDate); OracleConnection myOracleConnection = (OracleConnection)myConnection; myPreparedStatement.setClob(4, oracle.sql.CLOB.empty_lob()); int myRowCount = myPreparedStatement.executeUpdate(); myConnection.commit(); System.out.println("Successful update of "+myRowCount+" row"); //myReader.close(); myPreparedStatement.close(); //Now select the clob from the row just created. String mySql = "select XML_DATA from AMC_NEWB_XML where SESSION_ID = ? FOR UPDATE"; CallableStatement myCallableStatement = myConnection.prepareCall(mySql); myCallableStatement.setString(1, mySessionId); boolean myRes = myCallableStatement.execute(); System.out.println("Retrieved the CLOB from the DB");
Use preparedStatment as you did when you registered the empty CLOB.
ResultSet rs = myPreparedStatement.execute(); rs.next(); CLOB myClob = ((OracleResultSet) rs).getCLOB("XML_DATA"); // go to work on you CLOB
Dig Deeper on Oracle Application Server
Related Q&A from John Garmany
I get the ORA-12541 error message when I try to connect through Forms6i and Reports6i Builder. I've started the listener. I have no problems ...continue reading
I am facing the ORA-04076 error. I googled the error but was unable to understand it. What exactly do I need to do to solve this? I am using Toad.continue reading
We are using Oracle Database. In our client site, we have 500 users using the database at one time. Sometimes the database objects become invalid ...continue reading
Have a question for an expert?
Please add a title for your question
Get answers from a TechTarget expert on whatever's puzzling you.