aspose file tools*
The moose likes JDBC 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
Bookmark "inserting long text into Oracle CLOB " Watch "inserting long text into Oracle CLOB " New topic
Author

inserting long text into Oracle CLOB

Tom Griffith
Ranch Hand

Joined: Aug 06, 2004
Posts: 257
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..

A NOT NULL VARCHAR2(50)
B CLOB

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 );
clob.open( oracle.sql.CLOB.MODE_READWRITE );
clob.setString(2,four_hundred_fifty_character_long_string);
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: 257
after further review, i found that the default display length for CLOB, LONG and BLOB datatypes in SQL plus is 80 characters...so 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: http://aspose.com/file-tools
 
subject: inserting long text into Oracle CLOB
 
Similar Threads
Statement & PreparedStatement difference?
why won't clob open
Problem Special character handling
updating a CLOB field using oracle
Problem with inserting into MS Access Memo field.