aspose file tools*
The moose likes JDBC and the fly likes How to convert a java.sql.CLOB object to String 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 "How to convert a java.sql.CLOB object to String" Watch "How to convert a java.sql.CLOB object to String" New topic
Author

How to convert a java.sql.CLOB object to String

Ankit Gandhi
Greenhorn

Joined: Nov 03, 2006
Posts: 27
Hi,

I have a PL/SQL procedure �reorganize_report� which returns a CLOB object. This proc is being called through a java file named ReportDAO.java in the following way-

csmt = con.prepareCall("{call report_spk.reorganize_report(?,?,?,?) }");
csmt.setObject(1,(Object)reportId,java.sql.Types.CHAR);
csmt.registerOutParameter(7,java.sql.Types.CLOB);
csmt.registerOutParameter(8,java.sql.Types.CLOB);
csmt.registerOutParameter(9,java.sql.Types.CLOB);
csmt.execute();


I am retrieving the Clob�s like this � (the CLOB object is of java.sql.CLOB class)
Clob sourcelocationLst = csmt.getClob(7);
Clob newlocationLst = csmt.getClob(8);
Clob fileNameLst = csmt.getClob(9);

Now I need to convert this CLOB into a String object.
I tried using the toString() function present for CLOB�s but it gives me the following o/p - oracle.sql.CLOB@66c9b250

Can anybody help me out with this?
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 13867
    
  10

Have a look at the API documentation of java.sql.Clob.

Clob contains several methods that you could use: getCharacterStream(), getSubString(), ...


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to convert a java.sql.CLOB object to String
 
Similar Threads
How to convert a String to java.sql.Clob?
How to Convert a java.sql.CLOB object to String
How to insert CLOB object into DB?
Clob to String (Using Hibernate)
Converting a String to Clob for insert into DB