Solved

UTF problem with Oracle Thin driver

Posted on 2002-07-24
9
1,613 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

 
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

What Is Transaction Monitoring and who needs it?

Synthetic Transaction Monitoring that you need for the day to day, which ensures your business website keeps running optimally, and that there is no downtime to impact your customer experience.

Question has a verified solution.

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

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
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 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:

717 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