5th Cross

my writings about java, eclipse and musings about technology

Archive for February 2009

Reading from CLOB in java through JDBC

leave a 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

Written by Phani Kumar

February 21, 2009 at 10:30 am

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

Tagged with , ,

Follow

Get every new post delivered to your Inbox.