Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / Databases / March 2004

Tip: Looking for answers? Try searching our database.

Updating a row containgin a CLOB in Oracle with JDBC

Thread view: 
Rolf - 11 Mar 2004 02:08 GMT
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.
Lee Fesperman - 15 Mar 2004 04:27 GMT
> Hi:
>   I need to update a CLOB field in a table with JDBC, using Oracle. Here
[quoted text clipped - 18 lines]
>
> Sot what do I do with the clob in order to update the row?

createStatement() with no parameters produces resultsets that are read only. Use the 2
int parameter version of createStatment() to get updatable resultsets (from it).

Also, I think you'll need to do:

 rs.updateClob(2, clob);

after you change the clob and before you do updateRow().

I don't know Oracle in this area. All the above is just straight JDBC info that you can
get from the Sun's docs.

Signature

Lee Fesperman, FirstSQL, Inc. (http://www.firstsql.com)
==============================================================
* The Ultimate DBMS is here!
* FirstSQL/J Object/Relational DBMS  (http://www.firstsql.com)



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.