简体   繁体   English

使用Java读取Paradox数据库时出现编码问题

[英]Encoding issue while reading Paradox database using Java

I have Java application (using JDK 1.7) which is reading Paradox files (*.db). 我有Java应用程序(使用JDK 1.7)正在读取Paradox文件(* .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. 我试图将字符集指定为“ UTF-8”,但是也没有用。

Original code to read ResultSet looks like this: 读取ResultSet的原始代码如下所示:

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. 我也尝试过使用rs.getBytes(),然后将结果传递给新的String并在承包商中指定编码,但是效果也不好。

Does any one has any idea of what is missing. 是否有人对缺少的东西有任何想法。

You don't say which version of Paradox tables you are using. 您没有说要使用哪个版本的Paradox表。 Thru ver 4.5 paradox was a dos-based program. 通过版本4.5悖论是基于dos的程序。 Later it became Paradox for Windows. 后来它成为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. 但是,自从回到早期的dos版本以来,Paradox就支持西里尔字母和其他字符集,以及以后的版本。 These were interpreted using "code pages", a technology of the time. 这些使用当时的技术“代码页”进行解释。 They were still ascii tables - probably before unicode. 它们仍然是ascii表-可能在unicode之前。 I'm not sure about later. 我不确定以后。

So, I think the idea is to implement ascii code pages. 因此,我认为该想法是实现ASCII代码页。 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. 这些使用扩展的ascii字符,尤其是“国际”字符使用128-168。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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