5th Cross

my writings about java, eclipse and musings about technology

Reading from CLOB in java through JDBC

with one comment

Here is a code snippet that I have used to read from a CLOB, Oracle 10g instance.

PreparedStatment ps = connection.prepareStatement
("SELECT clobcolumn from clobtable");
ResultSet rs = ps.executeQuery();
while(rs.next())
{
oracle.sql.CLOB clobValue = (oracle.sql.CLOB)rs.getCLOB(1);
BufferedReader reader = new BufferedReader(new
InputStreamReader(clobValue.getAsciiStream()));
String read = null;
StringBuffer buffer = new StringBuffer();
while((read = reader.readLine()) != null )
{
buffer.append(read);
}
}
Digg This
About these ads

Written by Phani Kumar

February 21, 2009 at 10:30 am

Posted in CLOB, code, Code Snippet, database, java, JDBC, sql

Tagged with , ,

One Response

Subscribe to comments with RSS.

  1. tnx, Phani!

    bool

    June 4, 2013 at 5:14 pm


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: