?
Solved

UTF problem with Oracle Thin driver

Posted on 2002-07-24
9
Medium Priority
?
1,624 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
Independent Software Vendors: 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 400 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

Industry Leaders: 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!

Question has a verified solution.

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

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
The viewer will learn how to implement Singleton Design Pattern in Java.
Suggested Courses
Course of the Month15 days, 12 hours left to enroll

850 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