trying to retreieve CLOB data from oracle database

hello I am trying to retreive a clob data from database. I am passing "country" to get "information". after submitting data it is showingSQLException caught: General error.

whatz wrong.?

import java.io.*;

import javax.servlet.*;

import javax.servlet.http.*;

import java.sql.*;

publicclass ClobTest2extends HttpServlet{

publicvoid doGet( HttpServletRequest req, HttpServletResponse res )

throws ServletException, IOException

{

Connection conn =null;

Statement st =null;

ResultSet rs =null;

res.setContentType("text/html" );

PrintWriter out = res.getWriter();

String coun$ ="";

coun$ = req.getParameter("coun" );

try{

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

conn = DriverManager.getConnection("jdbc:odbc:clobtester","temp","sol" );

st = conn.createStatement();

rs = st.executeQuery("SELECT information FROM testclob WHERE country = '"+coun$+"' ");

while( rs.next() )

out.println(rs.getClob(1) );

}

catch( ClassNotFoundException e )

{

out.println("Could not load database driver" + e.getMessage() );

}

catch( SQLException e )

{

out.println("SQLException caught: " + e.getMessage() );

e.printStackTrace();

}

catch( Exception e )

{

System.err.println("Problem closing the database" );

}

try{

st.close();

conn.close();

}catch( Exception e )

{

System.err.println("Problem closing the database" );

}

}

}

[3064 byte] By [tomal123a] at [2007-11-26 20:00:26]
# 1

this

out.println(rs.getClob(1) );

is most probably not going to work.

You need to use the methods of the Clob class to fetch the data. Sometimes, drivers only allow you to grab a certain number of characters from the clob at a time, which may be the problem with calling toString on the clob in the above code.

dmbdmba at 2007-7-9 22:57:57 > top of Java-index,Java Essentials,Java Programming...
# 2
but it is generating SQLException: General error
tomal123a at 2007-7-9 22:57:57 > top of Java-index,Java Essentials,Java Programming...