• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

updating a CLOB field using oracle

 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 227
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Look at the other "executeQuery" methods on the statement. You should see one that allows you to specify the ResultSet type.
 
Water! People swim in water! Even tiny ads swim in water:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic