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 -> Problem with Oracle 10g + latest 10g JDBC Thin driver + NCLOB's of 1K-32K in size

Problem with Oracle 10g + latest 10g JDBC Thin driver + NCLOB's of 1K-32K in size

From: John Hendrikx <hjohn_at_please.remove.this.xs4all.nl>
Date: Tue, 26 Apr 2005 14:33:02 +0200
Message-ID: <426e34ff$0$166$e4fe514c@news.xs4all.nl>


I'm having a problem using NCLOB fields from a JDBC application. The database is using the "Unicode standard UTF-8 AL32UTF8" charset, which I selected during the install of the Oracle 10g Server.

I've created a small application which INSERTs records with a NCLOB field of varying lengths, using the setStringForClob() function which is new in the 10g thin driver. I use a SELECT to get the INSERTed data back, and find that everything works as it should as long as the text in the field is smaller than 1024 characters. It also works as it should when the text is larger than 32K characters, however anything between 1K and 32K characters results in data which has not been correctly converted to the right character set.

The incorrectly converted data can be converted manually to the correct charset using the Java getBytes(String charSet) function and then creating a new String() using the correct charset parameters. This results in the correct data, but it is prefixed with some garbage (I assume that this is some internal information the driver adds to its strings).

The string I'm using does not contain any special characters (it's just "01234556789abcdef" repeated).

To summarize:

1-1024 characters = OK
1025-32K characters = Garbage
32K+ characters = OK

A possible work-around involves changing the way setStringForClob works.

   It currently uses the setString() function internally when the text is less than about 32K characters; so it seems the setString function is at fault when handling text longer than 1K characters. A work-around could only call setString() if the string was less than 1K characters, however this would involve hacking the thin driver.

There are no problems if I simply use CLOB fields, however we need NCLOB for unicode support in our application.

Could anyone possible shed some light on this problem?

--

John Hendrikx
Senior Java Developer
TOPdesk
Received on Tue Apr 26 2005 - 07:33:02 CDT

Original text of this message

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