I am trying to convert my clob object to string to display that on my JSTL page for that I am writting the following code
public String convertClobToString(Clob clob){
String toRet="";
if(clob!=null)
{
try
{
long length=clob.length();
toRet=clob.getSubString(1, (int)length);
}
catch(Exception ex)
{
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
ex.printStackTrace();
}
}
return toRet;
}
but while counting the length using "long length = clob.length()" its throwing following exception
java.sql.SQLException: Must be logged on to server
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:179)
at oracle.jdbc.dbaccess.DBError.check_error(DBError.java:1160)
at oracle.jdbc.ttc7.TTC7Protocol.assertLoggedIn(TTC7Protocol.java:2196)
at oracle.jdbc.ttc7.TTC7Protocol.lobLength(TTC7Protocol.java:2698)
at oracle.sql.LobDBAccessImpl.length(LobDBAccessImpl.java:468)
at oracle.sql.CLOB.length(CLOB.java:214)
at org.hibernate.lob.SerializableClob.length(SerializableClob.java:33)
at com.starcj.cmt.application.dao.ApplicationDaoImpl.convertClobToString(ApplicationDaoImpl.java:110)
at com.starcj.cmt.termsandcondmgmt.dao.TermsAndCondDaoImpl.getAllActiveTermsandcond(TermsAndCondDaoImpl.java:91)
at com.starcj.cmt.termsandcondmgmt.service.TermsAndCondServiceImpl.getAllActiveTermsAndCond(TermsAndCondServiceImpl.java:43)
at com.starcj.cmt.termsandcondmgmt.controller.TermsAndCondListingCMTController.handleRequest(TermsAndCondListingCMTController.java:66)
at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:875)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:807)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:571)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:501)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Unknown Source)
Exceptoin isMust be logged on to server
but I am getting the clob object from database