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

Home -> Community -> Usenet -> c.d.o.server -> NCLOB fields and CLOB.createTemporary does not work

NCLOB fields and CLOB.createTemporary does not work

From: John Hendrikx <hjohn_at_please.remove.this.xs4all.nl>
Date: Wed, 27 Apr 2005 12:28:06 +0200
Message-ID: <426f6939$0$154$e4fe514c@news.xs4all.nl>


I'm using Oracle 9i, using the latest thin JDBC Java driver. I'm trying to insert a NCLOB into the database. The recommended way to do this is to use CLOB.createTemporary() as you can see in the code below. This code works fine for CLOB fields, but fails with a 'ORA-12704: character set mismatch' when the field is NCLOB.

Any help with this problem would be appreciated. This code works fine under Oracle 10g, but we cannot force our customers to upgrade just for unicode support.

We're using a unicode character set for the database, but the code fails on non-unicode character set installs as well.

Any help with this would be appreciated.

package nl.ogdsoftware.tas.test;

import java.io.IOException;
import java.io.Reader;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

import oracle.sql.CLOB;

public class OracleNClobProblem {

     public static void main(String[] args) throws SQLException, IOException {

         Class.forName("oracle.jdbc.driver.OracleDriver");
         Connection c = 

DriverManager.getConnection("jdbc:oracle:thin:@pc1143:1521:utestdb", "user", "pass");

         Statement s = c.createStatement();

         s.execute("CREATE TABLE TESTTABLE (nclobcolumn NCLOB)");

         PreparedStatement ps = c.prepareStatement("INSERT INTO TESTTABLE (nclobcolumn) VALUES (?)");                                 

         CLOB clob = CLOB.createTemporary(c, false, CLOB.DURATION_SESSION);                         

         clob.putChars(1, "0123456789abcdef".toCharArray());                                 

         ps.setObject(1, clob);                                 

         ps.execute();  /* Fails with: java.sql.SQLException:
                           ORA-12704: character set mismatch */
     }

}
--
John Hendrikx
Received on Wed Apr 27 2005 - 05:28:06 CDT

Original text of this message

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