Handling of CLOB type in Weblogic, JDBC

Hi All,

The below simple example will demonstrate the handling of CLOB in you JDBC call.

import java.sql.Clob;

public String readMyCLOB(int recordId){

…. code for connection,statement creation

String clobData=null;
cstmt.registerOutParameter(1, Types.CLOB);

Clob clob = cstmt.getClob(2);
if (clob != null) {
BufferedReader br = new BufferedReader(clob
while ((bufferedLine = br.readLine()) != null) {
buffOutput.append(bufferedLine + ‘\n’);
clobData = buffOutput.toString();
}catch(Exception ex){
return clobData;

***Note: Always import the CLOB,Array etc types from core JDBC pacakge(java.sql.*) to avoid any ClassCastExceptions in the laying Application servers.***

R Vashi

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.