Skip to Main Content

Java Database Connectivity (JDBC)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

jdbcodbcDriver uses the wrong charSet for interpreting the result set data

843854Jun 25 2003 — edited Nov 8 2005
Hi everyone,

I?m having trouble getting results from a MS Access database which uses Greek characters. All the characters in the range 0-127 are returned good but I get ??? for all above 127.

Here is some more details:

OS: win2k
Local setting for current user: Greek (not that it makes a difference)
Default Language setting for the System: English (Astralia). This uses charSet Cp1252 or ISO 8859-1 encoding.

Environment: JBuilder 7.0
JDK: 1.4.1

DB: MS Access
DB charSet: Cp1253 (Greek encoding or ISO 8859-7)

Connection method:
...
java.util.Properties prop = new java.util.Properties();
prop.put("user" , userName);
prop.put("password" , password);
//driver is "sun.jdbc.odbc.JdbcOdbcDriver";

//none of these work
//prop.put("charSet", "UTF-8");
//prop.put("charSet", "Greek");
prop.put("charSet", "Cp1253");
connection = DriverManager.getConnection(MY_ACCESS_DB,prop);
...

DataSet Access method:
...
// run query and get resultSet rs here
char[] cBuff= new char[1000];
// I have tried getString(), getBytes(), getBinaryStream also
Reader rReader = rs.getCharacterStream(3);
BufferedReader fIn = new BufferedReader(rReader);
int res = fIn.read(cBuff, 0, 999);
// contents of cBuff is incorrect here
...

I have also used -Dfile.encoding=Cp1253 in command line which seems to change the default charSet of the JVM. Tested
String en = new InputStreamReader(System.in).getEncoding();
System.out.println("Default encoding: " + en);

By enabling trace and looking at the content of the resultSet object it shows that
rs.OdbcApi.charSet = "Cp1253"

So I'm absolutely stumped. The only possible problems I can think of is either a bug in the jdbcodbcDriver or in my native ODBC driver. The latter is less likely since I connected to the same datasouce using a different application and get the right result.

One more thing that may be helpful, if I set up the default charSet under Win2K to "Greek" (that is setting default language setting in Regional Options under Control Panel)
Everything works fine.

Is there anyone out there with answer to my problem?

Thanks in advance.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 6 2005
Added on Jun 25 2003
20 comments
1,196 views