简体   繁体   中英

Encoding issue while reading Paradox database using Java

I have Java application (using JDK 1.7) which is reading Paradox files (*.db). It works well with Latin characters. I am trying to make this application to display Cyrillic characters correctly, however constantly getting unredable results.

Original code to connect to database:

Class.forName(DB_DRIVER);
String dbUrl = "jdbc:odbc:Driver={Microsoft Paradox Driver (*.db )};DBQ=" + workingDb + ";READONLY=true";
return DriverManager.getConnection(dbUrl);

I've tried to pass additional properties while getting connection:

java.util.Properties prop = new java.util.Properties();
prop.put("charSet", "windows-1251");            
return DriverManager.getConnection(dbUrl, prop);

however that didnt do anything. I've tried to specify charset as "UTF-8", but that didnt work as well.

Original code to read ResultSet looks like this:

String title = rs.getString(7)

but title is not readable. I've also tried to use rs.getBytes() and then pass results to new String and specify encoding in the constractor but that didnt work as well.

Does any one has any idea of what is missing.

You don't say which version of Paradox tables you are using. Thru ver 4.5 paradox was a dos-based program. Later it became Paradox for Windows. The tables were similar but had some enhancement.

However, all the way back to early dos versions, Paradox supported Cyrillic and other character sets, and more later. These were interpreted using "code pages", a technology of the time. They were still ascii tables - probably before unicode. I'm not sure about later.

So, I think the idea is to implement ascii code pages. Of course, this is dependent on whether that is how the data was entered originally. These used the extended ascii characters, especially 128-168 for "international" characters.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM