CLOB to String conversion
926625Jul 18 2012 — edited Jul 19 2012Hello to all,
I am new to java and Java Web Services. I am accessing Data Base of Oracle.
I am getting data in CLOB form. I want to convert it in to String data type.
My code of Java Web Service is :
public String getNotificationCount(String user_name){
con=getConnection();
Clob cl=null;
try{
cst=con.prepareCall("{?=call notifications_count (?)}");
cst.registerOutParameter(1,Types.VARCHAR);
cst.setString(2,user_name);
cst.execute();
rs = (ResultSet)cst.getObject(1);
cl=rs.getClob(1);
//int i = (int)cl.length();
//s = cl.getSubString(1,i);
}catch(Exception e){
System.out.println(e);
}
return cl.toString();
}
I am getting error after deployment at after invoke Web Service as :
12/07/18 17:21:27 java.lang.ClassCastException: java.lang.String
2012-07-18 17:21:27.656 ERROR OWS-04046 Caught exception while handling request:
java.lang.NullPointerException java.lang.NullPointerException
Help me out from this as soon as possible.