当前位置:首页 > 开发 > 数据库 > 正文

Is it a bug in MySQL or in java-connector?

发表于: 2013-11-19   作者:丁林.tb   来源:转载   浏览次数:
摘要: Description          In mysql-connector-java-5.1.27, the charset utf8mb4 is supported. But the steps and result bellow looks buggy. 1、  set character_s

Description

         In mysql-connector-java-5.1.27, the charset utf8mb4 is supported. But the steps and result bellow looks buggy.

1、  set character_set_server=gbk in my.cnf

2、  start mysql

3、  execute  set global character_set_server=utfmb4;

4、  insert a data with utf8mb4 characters

Result: error data inserted.

 

Analysis

         Direct reason: Java connector believes that the server use gbk as the default set, so deal the data with the rule of gbk;

         Deeper reason:

1\ set global character_set_server=utfmb4 just change the global_system_variables, but not the default_charset_info and default_character_set_name.

2\ when handshake, MySQL server writes server characteristics to client, using default_charset_info->number, 28, which is the CharsetIndex of gbk.

 

Compare

         As comparison, the steps change to

1、  set character_set_server= utfmb4 in my.cnf

2、  insert a data with utf8mb4 characters

Result: correct data inserted.

         Because the default charset is utfmb4 now, the connector treats dada correctly.

Discussion

         There are two ways to resolve this problem.

         1\ MySQL sends the current character info number in global_system_variables when handshake

         2\ Java connector get the correct character to use by “select @@character_set_server;”

 

So , is it a bug for MySQL or java-connector?

 

Is it a bug in MySQL or in java-connector?

  • 0

    开心

    开心

  • 0

    板砖

    板砖

  • 0

    感动

    感动

  • 0

    有用

    有用

  • 0

    疑问

    疑问

  • 0

    难过

    难过

  • 0

    无聊

    无聊

  • 0

    震惊

    震惊

编辑推荐
mysql 5.6.10版本 GTID模式时,备机salve线程执行SQL,主键冲突的话会导致自己的binlog异常,此时如
先说遇到的问题: java.lang.Thread.State: RUNNABLE at java.net.SocketInputStream.socketRead0(Na
朋友们先回答两个问题: select SQL_CALC_FOUND_ROWS * from product where 1=1 order by pid asc l
我在使用firebug,调我的ajax程序,我会查看它的输出的json,如下图,但是你会发现,它的输出会重复三
不兼容的类 如果你尝试反序列化老代码生成的文件的话。。。 URL配置错误 当你把一个错误的REST URL放
最近netty发现这个问题,偶发情况下,所有的server worke都在等待: "New I/O server worker #1-7"
我在使用firebug,调我的ajax程序,我会查看它的输出的json,如下图,但是你会发现,它的输出会重复三
作者:Vamei 出处:http://www.cnblogs.com/vamei 欢迎转载,也请保留这段声明。谢谢! 前记:偶然
Bug Tracker 使用笔记(有图有真相) 目的:管理Bug,完善业务流程。 前提条件:BugTracker是基于II
初次启动火狐的界面并且默认是最大化的情况下,第一个业签时会发现火狐的浏览器无法达到下边框,请看
版权所有 IT知识库 CopyRight © 2009-2015 IT知识库 IT610.com , All Rights Reserved. 京ICP备09083238号