Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Problems with CLOB in JDBC

Problems with CLOB in JDBC

From: Tobias Kjær Tobiasen <news1_at_dont.remove.nospam.tobiasen.dk>
Date: Thu, 30 Jan 2003 14:14:01 +0100
Message-ID: <b1b8ep$f1i$1@news.net.uni-c.dk>


Hello

I am trying to store a long string in a CLOB using JDBC.

Here is my code:

PreparedStatement ps = connection.prepareStatement("insert into Tester (a) VALUES (?)");
oracle.sql.CLOB clob = oracle.sql.CLOB.createTemporary(connection, true, oracle.sql.CLOB.DURATION_SESSION);
Writer writer = clob.getCharacterOutputStream(); try {

    writer.write(myString);
    writer.close();
}

catch (IOException e) {

    throw new RethrownExceptionAsRuntimeException(e);
}

ps.setClob(1, clob);
ps.executeUpdate();

This works well with very long strings :-) But if I try to insert a special char (like the EURO or any other non ascii unicode char) I get the exception below.

Is there a workaorund or another way to store long strings (>5000 chars) in a CLOB?

Tobias

java.sql.SQLException: No more data to read from socket

        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.MAREngine.unmarshalUB1(MAREngine.java:963)
        at oracle.jdbc.ttc7.MAREngine.unmarshalSB1(MAREngine.java:893)
        at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:369)
        at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1891)
        at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteFetch(TTC7Protocol.java:1093)
    

    at oracle.jdbc.driver.OracleStatement.executeNonQuery(OracleStatement.java:2047)     

    at oracle.jdbc.driver.OracleStatement.doExecuteOther(OracleStatement.java:1940)     

    at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:2709)     

    at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:589)

        at Tester.main(Tester.java:38) Received on Thu Jan 30 2003 - 07:14:01 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US