Java开发网 Java开发网
注册 | 登录 | 帮助 | 搜索 | 排行榜 | 发帖统计  

您没有登录

» Java开发网 » Database/JDBC/SQL/JDO/Hibernate  

按打印兼容模式打印这个话题 打印话题    把这个话题寄给朋友 寄给朋友    该主题的所有更新都将Email到你的邮箱 订阅主题
flat modethreaded modego to previous topicgo to next topicgo to back
作者 关于java访问access文件
cyberpeng





发贴: 3
积分: 0
于 2006-12-11 17:38 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
Java访问Access的*.mdb文件。使用了以下的访问方式:

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
//Edit DB url
String url = "jdbc:odbc:driver={Microsoft Access Driver (*.mdb)};DBQ=db.mdb;characterEncoding=\"utf-8\"";
//Create connection
Connection con = DriverManager.getConnection(url, "user", "password");
Statement stmt = con.createStatement();
String sql = "SELECT * FROM DICT";
ResultSet rs = stmt.executeQuery(sql);
byte[] b = rs.getBytes(1);
String s = rs.getString(1);
...

英文系统,安装了中文、日文语言包。系统在日文状态下工作。
在access文件中用中文输入法输入“级”(简体中文)。用日语输入法输入“級”。在Access中,“级”字是个小写的字,后面的“級”是正常显示。个人猜测是因为当前日文字体中没有中文的“级”字,在其他字体(NSimSun?)中找了个来,所以会显得小。
但不管怎样,这里显示的还是个字。但是使用上述代码取出该字段(Text类型)值时,所有小字(日文中没有的字),取出得到的都是“?”(0x3F)。怎么才能取到保存的汉字呢?也试过其他characterEncoding,但是没有起作用。哪位对此有研究的,还请不吝指教。



作者 Re:关于java访问access文件 [Re:cyberpeng]
why

問題兒童

总版主


发贴: 4629
积分: 388
于 2006-12-12 19:17 user profilesend a private message to usersend email to whysearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
Maybe the JDBC driver does not support unicode properly
Why Would you use Access?



作者 Re:关于java访问access文件 [Re:cyberpeng]
cyberpeng





发贴: 3
积分: 0
于 2006-12-14 21:05 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
偶然遇到的一个问题,放在那里解决不了,感觉不是太好。
确实可能是数据库驱动的问题。用Access打开该mdb文件的时候,至少能看到该文字,但只能取到问号。
汗啊




flat modethreaded modego to previous topicgo to next topicgo to back
  已读帖子
  新的帖子
  被删除的帖子
Jump to the top of page

   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923