救急!!用过Jdbc连接MySQL4.1以后版本的麻烦帮个忙!,见者有分

pateric 2004-07-10 01:26:55
我以前使用MySQl4.0.18 + Connector/J 3.1.3 Alpha版
做数据库操作一切都很正常
但是由于这个版本的MySQL不支持一些嵌套查询的SQL语句,我现在改用MySQL4.1.1
可随之出现的问题是中文不能正确显示了,之前是没有这个问题的
我连库还是一样连的
jdbc:mysql://localhost/dbname?useUnicode=true&characterEncoding=gb2312
后来我看到Mysql的文档中有这么一段
Prior to MySQL Server 4.1, Connector/J supported a single character encoding per connection, which could either be automatically detected from the server configuration, or could be configured by the user through the useUnicode and characterEncoding properties.

Starting with MySQL Server 4.1, Connector/J supports a single character encoding between client and server, and any number of character encodings for data returned by the server to the client in ResultSets.

The character encoding between client and server is automatically detected upon connection. The encoding used by the driver is specified on the server via the configuration variable 'character_set' for server versions older than 4.1.0 and 'character_set_server' for server versions 4.1.0 and newer. See the "Server Character Set and Collation" section in the MySQL server manual for more information.

To override the automatically-detected encoding on the client side, use the characterEncoding property in the URL used to connect to the server.

When specifying character encodings on the client side, Java-style names should be used. The following table lists Java-style names for MySQL character sets:

MySQL Character Set Name Java-Style Character Encoding Name
-----------------------------------------------------------
gbk GBK
gb2312 EUC_CN
latin1 ISO8859_1
............
文档在这儿:http://dev.mysql.com/doc/connector/j/en/index.html#id2803738
我理解是不是我连库的URL中的characterEncoding 应该设置为Java-style的EUC_CN或者GBK(原来是gb2312),但是这样子还是不行

麻烦各位给我提提建议呢,我该怎么办?
...全文
144 11 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
Leemaasn 2004-07-12
  • 打赏
  • 举报
回复
我觉得你试试看,保存到数据库里之前都将字符编码成8859_1,然后再保存
取出来,再重新编码。。。
pateric 2004-07-12
  • 打赏
  • 举报
回复
楼上的,麻烦看一下我的贴再回还可以啊?
liyong33 2004-07-12
  • 打赏
  • 举报
回复
String connectionString= "jdbc:mysql://localhost/test?useUnicode=true&characterEncoding=gb2312";



wdiy 2004-07-12
  • 打赏
  • 举报
回复
我也想知道
pateric 2004-07-12
  • 打赏
  • 举报
回复
有没有人知道的啊?帮帮忙啊!
pateric 2004-07-12
  • 打赏
  • 举报
回复
但是我觉得每次存库和取库的时候都做转换是不是太烦烦了
即使是自己封装一个方法
我想寻求一个简单点办法
playboylee 2004-07-11
  • 打赏
  • 举报
回复
E文不好,帮你顶。
wind_rain 2004-07-11
  • 打赏
  • 举报
回复
minghuitian 2004-07-10
  • 打赏
  • 举报
回复
up
weidy 2004-07-10
  • 打赏
  • 举报
回复
useUnicode=true&characterEncoding=gb2312
改成
useUnicode=true&characterEncoding=gb2312
试试吧
nwpulipeng 2004-07-10
  • 打赏
  • 举报
回复
up

67,550

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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