insert clob into oracle table through jsp

Posted on 2005-05-09
Last Modified: 2007-12-19
I'm trying to insert data in clob oracle table through jsp, we use jdbc.odbc driver
tomcat 4.1.18 as our server and jdk1.3.x, oracle 9i
and I have this error:  

java.lang.ClassCastException: sun.jdbc.odbc.JdbcOdbcConnection
        at oracle.jdbc.driver.OracleConnection.physicalConnectionWithin(
        at oracle.sql.CLOB.createTemporary(
        at oracle.sql.CLOB.createTemporary(

Hopefully this provide enough info, could you please tell me what is wrong with my codes?  thanks a lot for helping.
               PreparedStatement pstmt = conn.prepareStatement("insert into Notes VALUES (" + SystemID + ",'" + UserID + "',sysdate, ?);");

               oracle.sql.CLOB clob = null;
               clob = CLOB.createTemporary(pstmt.getConnection(), true, CLOB.DURATION_SESSION);
               Writer clobWriter = clob.getCharacterOutputStream();
               OraclePreparedStatement opstmt = (OraclePreparedStatement)pstmt;
               opstmt.setCLOB(1, clob);
Question by:nictran
    LVL 29

    Accepted Solution

    I think there's an error in your SQL: an extra ;

    PreparedStatement pstmt = conn.prepareStatement("insert into Notes VALUES ( " + SystemID + ",'" + UserID + "',sysdate, ?)" );

    Have a look at this, it seems to be a much easier way to enter a CLOB into an Oracle db

    It's got some specific comments for Oracle 9

    LVL 29

    Expert Comment

    What is the object "Comments", is it a String or a character array?
    LVL 29

    Expert Comment

    and from the stacktrace, it seems that the error is in this line

      clob = CLOB.createTemporary(pstmt.getConnection(), true, CLOB.DURATION_SESSION);


      oracle.sql.CLOB newClob = oracle.sql.CLOB.createTemporary(conn, false, oracle.sql.CLOB.DURATION_CALL);
    LVL 3

    Expert Comment

    I'm pretty certain that you have to use the Oracle jdbc driver when using oracle.sql.CLOB.

    May I ask why you are using the jdbc-odbc bridge?

    LVL 29

    Expert Comment


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    The recent Microsoft changes on update philosophy for Windows pre-10 and their impact on existing WSUS implementations.
    For Sennheiser, comfort, quality and security are high priority areas. This paper addresses the security of Bluetooth technology and the supplementary security that Sennheiser’s Contact Center and Office (CC&O) headsets provide.  
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now