Solved

UTF problem with Oracle Thin driver

Posted on 2002-07-24
9
1,607 Views
Last Modified: 2011-10-03
Hi Experts,
  We are using oracle thin driver for connecting to oracle database in solaris 8 environment. The database has got some french characters which are stored in UTF-8 character format.
  The NLS_LANG is also set to UTF8 (Though thin driver does not use this setting we have set it).
  The problem is when we try to read some french characters from the database it throws the following error. Has anyone encountered such problems?.

Sql exception; PREVIOUS EXCEPTION: (java.sql.SQLException: Fail to convert between UTF8 and UCS2: failUTF8Conv)

The stack trace is as follows


java.sql.SQLException: Fail to convert between UTF8 and UCS2: failUTF8Conv

        at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:168)

        at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:210)

        at oracle.jdbc.dbaccess.DBError.check_error(DBError.java:829)

        at oracle.jdbc.dbaccess.DBConversion.failUTF8Conv(DBConversion.java:1746)

        at oracle.jdbc.dbaccess.DBConversion.utf8BytesToJavaChars(DBConversion.java:1585)

        at oracle.jdbc.dbaccess.DBConversion.utf8BytesToString(DBConversion.java:1445)

        at oracle.jdbc.dbaccess.DBConversion.CharBytesToString(DBConversion.java:384)

        at oracle.jdbc.driver.OracleStatement.getStringValue(OracleStatement.java:2571)

        at oracle.jdbc.driver.OracleResultSetImpl.getString(OracleResultSetImpl.java:305)

        at oracle.jdbc.driver.OracleResultSet.getString(OracleResultSet.java:1374)


Thankx in advance

regards
Rajesh
0
Comment
Question by:rajesh_bala
  • 4
  • 3
  • 2
9 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 7174133
>
The database has got some french characters which are stored in UTF-8 character format.
>>

Are you*sure* this is the case? A lot of software claims to use certain encodings but doesn't.  What characters are they?
0
 
LVL 10

Author Comment

by:rajesh_bala
ID: 7174185
I saw the characters getting displayed properly in french using Toad.

- But the same does not work with oracle thin driver. Do i need to set some parameters in the database server.
0
 
LVL 10

Author Comment

by:rajesh_bala
ID: 7174188
"Evaluaci¿n" - This is the string that is stored in the database. When i read this it throws the mentioned error.
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 86

Accepted Solution

by:
CEHJ earned 100 total points
ID: 7174219
The point is that somewhere along the chain, there is a problem with encoding translation. What you must do is confirm that the *source* is correct first.

Can you run some kind of sizeof() function on one of the words that will return the size *in bytes*? The example you gave above (which didn't come out right I think in this browser), if it contains any UTF-8-encoded characters which are higher than 0x7F [from memory], then the length in bytes will be greater than the number of characters. This will be a good test to see if the DB really *is* storing them as UTF-8.
0
 
LVL 10

Author Comment

by:rajesh_bala
ID: 7174246
Hi,
  I understand your point. But how do i check that the database is storing the french characters in UTF-8 character.
  The text that is appearing on "this" browser(Evaluaci¿n) is correct. This is what is stored in the database.
  Can u please guide me to check how the database is storing these french characters.

  I tried dump(FIELD_NAME) in oracle where FIELD_NAME is the name of the field that contains this french character.
  I got back the correct values. All the values are well within 255.
0
 

Expert Comment

by:SpideyMod
ID: 8147464
Administrative Action - Force Accepted

SpideyMod
Community Support Moderator @Experts Exchange
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 8147487
btw, when this action is taken, do we still get 'Good answer..' notifications? (i'm not sure if i can remember)
0
 

Expert Comment

by:SpideyMod
ID: 8147550
No.  For some reason, the "Good Answer" doesn't apply to force accepts.  In my expert account I struggle with this myself as I like to keep the good answer emails in a special folder. I just move the force-accepts there as well.
0
 
LVL 10

Author Comment

by:rajesh_bala
ID: 8151649
Hi CEHJ,
  I got an email that u have added some comments on this question. But I don't see those. Can u please repost the comments.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

808 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