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

How to insert and retrieve clob

jaya repaka

Joined: Nov 06, 2003
Posts: 18
Hi All,
In my application ,one datatype has been changed to clob(5000) from varchar2(4000).I wrote the following code to insert and select..(for Clob)

String value=requestComment.getComment();
StringReader r = new StringReader((String)value );
preparedStatement.setCharacterStream( 4, r, ((String)value).length());

// for retrieve(select)
myClob = resultSet.getClob(COMMENT_X);
Reader clobData = myClob.getCharacterStream();
CharArrayWriter writer=new CharArrayWriter();
int i=-1;
while((i = !=-1) {

I gave morethan 4000 character as input ,I am getting the following the error..

Mapping the following SQLException, with ErrorCode 17,410 and SQLState <null>, to a StaleConnectionException: java.sql.SQLException: No more data to read from socket

Please let me know if someone can help me..

Thanks in advance...

Karthikeyan Rajendraprasad
Ranch Hand

Joined: Apr 16, 2003
Posts: 70
in order to use setClob you need to have a Clob object. it can be created as mentioned below

set it as

Karthikeyan<br />SCJP 1.4, SCWCD.
wood burning stoves
subject: How to insert and retrieve clob
Similar Threads
Converting a String to Clob for insert into DB
use of CLOB,help me.
CLOB field in Oracle not being updated with JDBC
Limit character read using Reader?