aspose file tools
The moose likes JDBC and the fly likes updating a CLOB field using oracle Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Reply Bookmark "updating a CLOB field using oracle" Watch "updating a CLOB field using oracle" New topic
Author

updating a CLOB field using oracle

Rolf Johansson
Ranch Hand

Joined: Feb 25, 2004
Posts: 32
Hi:
I need to update a CLOB field in a table with JDBC, using Oracle. Here
is the code I have for retrieving the existing value and adding some more
text onto the CLOB:
try {
String stuff="XXXX";
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("select i, v from t where i='3' for update");
if (rs.next()) {
// clog is field #2
Clob clob = rs.getClob(2);
// concatenate the "stuff" String onto the existing value in the clob
((oracle.sql.CLOB)clob).putString(((oracle.sql.CLOB)clob).length()+1, stuff);
rs.updateRow();
}
}
When I run this I get the exception:
java.sql.SQLException: Invalid operation for read only resultset: updateRow
Sot what do I do with the clob in order to update the row?
TIA
- Rolf.
Dana Hanna
Ranch Hand

Joined: Feb 28, 2003
Posts: 227
Look at the other "executeQuery" methods on the statement. You should see one that allows you to specify the ResultSet type.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: updating a CLOB field using oracle
 
Similar Threads
Storing large String in CLOB
Question on update CLOB column when the column value is null
an example to insert data into Oracle Clob
help: lock problem during Clob update
JDBC insert into CLOB