• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

Reading CLOB object from Oracle

 
Ranch Hand
Posts: 485
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic