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 inserting long text into Oracle 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 "inserting long text into Oracle CLOB " Watch "inserting long text into Oracle CLOB " New topic

inserting long text into Oracle CLOB

Tom Griffith
Ranch Hand

Joined: Aug 06, 2004
Posts: 275
hello. If anybody has a minute, I am partially successful with inserting text into a CLOB. The problem is it's only a portion of the text.

this is the table desc..


however, when I try to insert a 450 character length string into B (the CLOB), it only seems to store the first 80 characters.

here is how i am populating the prepared statement...

statement.setString(1,"This is the text for A");

oracle.sql.CLOB clob=oracle.sql.CLOB.createTemporary(conn , false , oracle.sql.CLOB.DURATION_SESSION ); oracle.sql.CLOB.MODE_READWRITE );
statement.setClob(2, clob);

the clob inserts but like i said, it appears to truncate at 80 characters.

I plan on utilizing the prepared statement setAsciiStream stuff to generalize the code but i am suspecting the problem is lying with the CLOB itself or something at the database level. If anybody has any ideas, it would be greatly appreciated.

Thank you very much for reading.
[ July 18, 2008: Message edited by: Tom Griffith ]
Tom Griffith
Ranch Hand

Joined: Aug 06, 2004
Posts: 275
after further review, i found that the default display length for CLOB, LONG and BLOB datatypes in SQL plus is 80 i entered SET LONG = 500 into sql plus on the command line and it seems to display everything. i had thought of doing a SQL select on the field, which i am still going to do, to make sure it has everything.

thank you for reading.
I agree. Here's the link:
subject: inserting long text into Oracle CLOB
It's not a secret anymore!