-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Need help on reading CLOB column
PostPosted: Wed Nov 15, 2006 1:32 pm 
Newbie

Joined: Wed Jul 19, 2006 4:34 pm
Posts: 19
Hibernate Code - Reading CLOB Data
----------------------------------------------------------------------------------------------------------------------------------
mapping.xml
-------------
<property name="clobData" type="clob">
<column name="ClobData" />
</property>

java code
--------------
String clobHQL = "from ClobPOJO";
Query query = session.createQuery(clobHQL);

List result = query.list();

ClobPOJO clobPOJO = (ClobPOJO)result.get(0);
java.sql.Clob dataAsClob = clobPOJO.getClobData();

// FIRST WAY - Error
String dataAsString=dataAsClob.getSubString(1, (int) dataAsClob.length());

// SECOND WAY - Error
Reader reader=dataAsClob.getCharacterStream();
CharArrayWriter writer=new CharArrayWriter();
int i=-1;

while ( (i=reader.read())!=-1)
{
writer.write(i);
}

String dataAsString = new String(writer.toCharArray());


Error
========
java.io.IOException: [PWS0001] Function did not complete successfully.
at com.ibm.as400.access.AS400JDBCInputStream.read(AS400JDBCInputStream.java:305)
at java.io.BufferedInputStream.fill(BufferedInputStream.java:200)
at java.io.BufferedInputStream.read1(BufferedInputStream.java:239)
at java.io.BufferedInputStream.read(BufferedInputStream.java:294)
at com.ibm.as400.access.ConvTableReader.fillCache(ConvTableReader.java:180)
at com.ibm.as400.access.ConvTableReader.read(ConvTableReader.java:500)


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.