Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 2005
    Posts
    24

    Unanswered: Format string into oracle.sql.CLOB => exception

    Hi!

    I just want to convert a simply String or Document type into the Oracle CLOB datatype, because I use a stored Procedure with an CLOB argument.
    (not to mix with writing a CLOB into a oracle database).

    I need some help, I tried this here:

    public void setdataPackage(Document data, float cid) {
    Connection conn = null;
    CallableStatement cs = null;

    try {
    conn= pool.getConnection(2000);
    conn.setAutoCommit(false);

    CLOB newClob = CLOB.createTemporary(conn, false, oracle.sql.CLOB.DURATION_CALL);
    newClob.setString(1, data.toString());



    if(conn != null){
    cs = conn.prepareCall("{call SETDATAPACKAGE(?, ?)");
    try{
    //Inputvalues
    cs.setClob(1, newClob);
    cs.setFloat(2, cid);

    // execute PROCEDURE
    cs.execute();
    }
    catch(Exception e){
    System.out.println("CLOB Exception: "+ e);
    }
    cs.close();
    }
    else
    System.out.println("Connection faild!!!");
    }
    catch (SQLException e) {
    System.out.println("setDataPackage Exception: "+ e);
    }
    finally{
    try{
    conn.close();
    }
    catch(SQLException e){
    System.out.println("Connection Close Exception: "+ e);
    }
    }
    }


    follows this exception:
    SCHWERWIEGEND: Servlet.service() for servlet jsp threw exception
    java.lang.ClassCastException: snaq.db.CacheConnection
    at oracle.sql.CLOB.createTemporary(CLOB.java:754)
    at oracle.sql.CLOB.createTemporary(CLOB.java:716)
    at logon.Database.setdataPackage(Database.java:114)
    at org.apache.jsp.db_jsp._jspService(org.apache.jsp.d b_jsp:153)
    at org.apache.jasper.runtime.HttpJspBase.service(Http JspBase.java:97)
    at javax.servlet.http.HttpServlet.service(HttpServlet .java:802)
    at org.apache.jasper.servlet.JspServletWrapper.servic e(JspServletWrapper.java:322)
    at org.apache.jasper.servlet.JspServlet.serviceJspFil e(JspServlet.java:314)
    at org.apache.jasper.servlet.JspServlet.service(JspSe rvlet.java:264)
    at javax.servlet.http.HttpServlet.service(HttpServlet .java:802)
    at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:252)
    at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:173)
    at org.apache.catalina.core.StandardWrapperValve.invo ke(StandardWrapperValve.java:213)
    at org.apache.catalina.core.StandardContextValve.invo ke(StandardContextValve.java:178)
    at org.apache.catalina.core.StandardHostValve.invoke( StandardHostValve.java:126)
    at org.apache.catalina.valves.ErrorReportValve.invoke (ErrorReportValve.java:105)
    at org.apache.catalina.core.StandardEngineValve.invok e(StandardEngineValve.java:107)
    at org.apache.catalina.connector.CoyoteAdapter.servic e(CoyoteAdapter.java:148)
    at org.apache.coyote.http11.Http11Processor.process(H ttp11Processor.java:868)
    at org.apache.coyote.http11.Http11Protocol$Http11Conn ectionHandler.processConnection(Http11Protocol.jav a:744)
    at org.apache.tomcat.util.net.PoolTcpEndpoint.process Socket(PoolTcpEndpoint.java:527)
    at org.apache.tomcat.util.net.LeaderFollowerWorkerThr ead.runIt(LeaderFollowerWorkerThread.java:80)
    at org.apache.tomcat.util.threads.ThreadPool$ControlR unnable.run(ThreadPool.java:684)
    at java.lang.Thread.run(Thread.java:595)

  2. #2
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    Provided Answers: 1
    Quote Originally Posted by klaus1
    CLOB newClob = CLOB.createTemporary(conn, false, oracle.sql.CLOB.DURATION_CALL);
    RTFM: "In client applications DURATION_SESSION is appropriate."

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •