Solved

UTF problem with Oracle Thin driver

Posted on 2002-07-24
9
1,608 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying 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

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
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 …

756 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