aspose file tools*
The moose likes JDBC and the fly likes Reading CLOB object from Oracle Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Reading CLOB object from Oracle" Watch "Reading CLOB object from Oracle" New topic
Author

Reading CLOB object from Oracle

Parameswaran Thangavel
Ranch Hand

Joined: Mar 01, 2005
Posts: 485
All,
I am reading the String from my Oracle database which is stored as CLOB object.

below is the code snippet.

//columnNumber for the CLOB column in the database
oracle.sql.CLOB clob = (oracle.sql.CLOB)rs.getClob(columnNumber);

//Works fine for below line
//java.sql.CLOB clob = (java.sql.CLOB)rs.getClob(columnNumber);
inputStream = clob.asciiStreamValue();
int available = inputStream.available();

//available is zero for Oracle.sql.CLOB, but contains the value for java.sql.CLOB
byte[] buf = new byte[available];
int bytesRead = inputStream.read(buf);
inputStream.close();
//Printing the string object
System.out.println(new String(buf));


The above code works fine for SQL databse, but when i use the Oracle CLOB object its not returning any value. The variable available is zero for Oracle
but has the correct value for SQL database.

Any insight would help.

Thanks
Param
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Reading CLOB object from Oracle
 
Similar Threads
CLOB ClassCastException
why won't clob open
Storing large String in CLOB
CLOB field in Oracle not being updated with JDBC
ClassCastException Weblogic and Oracle CLOB object