File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes JDBC insert into CLOB Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "JDBC insert into CLOB" Watch "JDBC insert into CLOB" New topic

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 ); oracle.sql.CLOB.MODE_READWRITE );
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:
subject: JDBC insert into CLOB
jQuery in Action, 3rd edition