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)
|
|