关于jdbc的中文问题和jdk1.2的打印

bigchen 2000-01-10 06:44:00
我用jdbc连odbc访问access数据库,发现用insert into 不能添加中文,也有部分中文无法读出.
用jdk1.2打印,有什么方法可以有较快速度,和较高的质量.
...全文
260 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
zzj_mjz 2000-06-02
  • 打赏
  • 举报
回复
有同感,使用JDK1.1.5质量就比较高。
hongfei 2000-04-11
  • 打赏
  • 举报
回复
I am hungry for your scores.^o^
hongfei 2000-03-28
  • 打赏
  • 举报
回复
Now I have a way of solute chinese problem in java
(include jdbc-odbc bridge but as if only fit jdk 1.1.* and 1.0.*)
the way is using encoding way.

the "iso-8859-1" encoding is the most wide english encoding solution
supposing the chinese data is readed from file or database in String "sChData",
you must deal with the following code
" byte[] ch_byte = sChData.getBytes("iso-8859-1");
//here we force java vm to read chinese data in a english way
sChData = new String(ch_byte);
//and here we force to turn into unicode data",

in addition, when data writed to file or db , and use the following code
" byte[] ch_byte = sChData.getBytes();
//here we divide the string into byte array
sChData = new String(ch_byte,"iso-8859-1");
//and here we force to turn to the english way from
// the unicode byte array"

if you want to send data among threads, please use Reader/writer
in jdk 1.1.* or jdk 1.2.* to send the unicode data which are dealt
with the first way;

the way fit in all java editions except for jdbc in jdk1.2
(it is only now I have not solutions.)

My code is here (use chinese params of sql to
read the chinese data from database):

(environment :visualage for java 2.0)

import java.sql.*;
/**
* This type was created in VisualAge.
*/
class MyTest {
/**
* This method was created in VisualAge.
* @param args java.lang.String[]
*/
public static void main(String args[]) {
Connection con = null;
Statement myState = null;
ResultSet myRSet = null;
String url, sName;
try {
url = "jdbc:odbc:paper";
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con = DriverManager.getConnection(url, "", "");
myState = con.createStatement();
String sql = "select paperName from paper where author = \'张三\'";
byte[] ch_Byte = sql.getBytes();
sql = new String(ch_Byte,"iso-8859-1");
myRSet = myState.executeQuery(sql);
while (myRSet.next()) {
sName = myRSet.getString("paperName");
ch_Byte = sName.getBytes("iso-8859-1");
sName = new String(ch_Byte);
System.out.println("Name: " + sName);
}
} catch (Exception e) {
System.out.println("error: " + e.toString());
}
}
}



please send some scores to me!
it spends a week for me !!
^v^
土豆 2000-01-24
  • 打赏
  • 举报
回复
我也碰到JDBC不支持中文的事,哪位仁兄可以解决?
ahfei 2000-01-10
  • 打赏
  • 举报
回复
jdbc-odbc至今仍无解决中文问题的方法。找一个access的pure java驱动看看。

62,614

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧