aspose file tools*
The moose likes JDBC and the fly likes JDBC insert into CLOB Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "JDBC insert into CLOB" Watch "JDBC insert into CLOB" New topic
Author

JDBC insert into CLOB

Tom Griffith
Ranch Hand

Joined: Aug 06, 2004
Posts: 275
Hello. If anybody has a minute, I am trying to take a more JDBC approach to insert a CLOB into Oracle rather than relying on oracle.sql.CLOB.

In any case, this works via instantiating an oracle.sql.CLOB obect

oracle.sql.CLOB clob=oracle.sql.CLOB.createTemporary(conn , true , oracle.sql.CLOB.DURATION_SESSION );
clob.open( oracle.sql.CLOB.MODE_READWRITE );
clob.setString(1,current_string);
statement.setClob(i+1, clob);


however, Oracle can't seem to see the CLOB as a CLOB if i take a jdbc approach...I receive ORA-01461: can bind a LONG value only for insert into a LONG column...

StringReader reader = new StringReader(current_string);
InputStream is_reader = new ByteArrayInputStream(current_string.getBytes());
statement.setCharacterStream(i+1, reader, current_column_value.length());


i am thinking I need to do something to instantiate the CLOB so Oracle understands that it is a CLOB, is that right? Thank you...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JDBC insert into CLOB