Solved

UTF problem with Oracle Thin driver

Posted on 2002-07-24
9
1,600 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
 
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
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
hash value 2 38
pairs challenge 5 44
Systems talking to each other 5 108
Cipher Configuration on Apache HTTPD 4 17
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

708 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now