Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MS-Access encoding problem 1

Status
Not open for further replies.

tom62

Programmer
Nov 12, 2002
152
DE
I have problem reading non latin characters from a MS-Access 2000 or later table (Java 1.4.2 and 5.0). When I read a textfield that contains for example greek characters the string that I get back contains question marks.

Essentially my code looks like this:

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Properties props = new Properties();
props.put ("charSet", "UTF-8");
Connection c = DriverManager.getConnection("jdbc:eek:dbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=" + pDatabase, props);

Statement st = connection.createStatement();
ResultSet rs = st.executeQuery("SELECT myField FROM myTable");

I've tried many variations of ways to extract the data from the ResultSet, including getCharacterStream, getBytes, and getString (with various encodings such as "UTF8"), but non of them return greek, russian, chinese, etc. characters.

According to Microsoft, Access 2000 or later uses the Unicode character-encoding scheme to represent data in a textfield, so there should be no problem returning the correct characters in textfield using Java.

What am I doing wrong (apart from using MS-Access or not using a third party JDBC-Driver)?
 
Can you retrieve the values with a different technique than java and get correct characters?

If yes, store them in a file, and try to read from that file.
If they're still displayed wrong, you could look, whether your font supports those characters.

(A vague guess without access-experience).

seeking a job as java-programmer in Berlin:
 
> Can you retrieve the values with a different technique
> than java and get correct characters?

Yes, I have no problems reading these characters within MS-Access. I can also see these characters with a database viewer program that was written in Delphi.

> Do you store the value as UTF-8? For example:
> \U2363\u3253.......

According to information that I have the value should be stored in "raw" (whatever that means) UTF-8 format. I don't write anything in the database myself, I'm only trying to read from the database (which is a database of a shareware program that has not been developed by me; and is used all over the world).

I downloaded a trial copy of a HXTT Access driver and with that driver I have no problem displaying non-latin characters (in a JTable). I can however not use the driver, because my program is distributed as freeware and I don't have the money (nor the intention) to pay thousands of dollars (per single application) for a ODBC driver license.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top