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?
相关推荐
支持mysql-connector-java-5.6,mysql-connector-java-5.0.X以上
MySQL Connector/J是MySQL官方JDBC驱动程序。将下载的驱动包解压缩后,将MySQL-connector-Java-5.1.34-bin.jar拷贝到项目中 Connector/J 5.34包括JDBC-4.0功能的支持
mysql-connector-java-5.1.47.jar多用于数据库连接配置文件 映射产生实体等等
#资源达人分享计划# jdbc驱动,mysql连接数据库,该版本比较高,可弥补一些bug 主要结合博文进行学习
mysql JDBC驱动8.0.23版本
mysql-connector-java-8.0.12jar驱动,javajar,驱动mysql数据库
mysql-connector-java-5.0.0-beta-bin,看好5.0版本,要最新版去官网下载
mysql-connector-odbc-8.0.13-win32.msi Login Now or Sign Up for a free account. An Oracle Web Account provides you with ...Report and track bugs in the MySQL bug system Comment in the MySQL Documentation
VS C#开发中连接mysql数据库使用的dll文件,多个版本(v4.0 v4.5 v4.8)可供选择,下载解压后直接在项目中添加引用即可正常使用
mysql与c#的连接库6.4版本后可能有bug,连接数据库可能会提示:out of sync with server。这个老版本可以正常使用。
本版本修复 JDK的Bug1–数组切割 JDK的Bug2–三元运算符 JDK中不算Bug的Bug–ArrayList可通过构造函数传入非指定泛型的List并在get时出错
Alibaba-Java-Coding-Guidelines-Fix-Some-Bug-1.6-2023.2-2.1
极具吸引力的是官方在8.0版本上对MGR bug 的持续修复和功能完善,以及对数据库整体性能的提升,使得不少企业在生产开始使用8.0版本。对于银行业而言,虽然基本上还是采用其上一个版本-5.7,但研究、测试并使用8.0...
这是一个mysql jdbc驱动程序,用来帮助处理hive中遇到的一些问题,没有这个jar包可能导致hive 无法与mysql互通,或者配置时出现错误
websocket前后台数据交互失败,并且报java.lang.IncompatibleClassChangeError
-Bug with Locate when a NULL value is present in the index field is fixed -Bug with IndexFieldNames when DataTypeMapping is enabled is fixed -Bug with freeing memory in the TDADataSet.Lookup method is...
-Bug with processing calculated and lookup fields in the SmartFetch mode is fixed -Bug with getting RecordCount when QueryRecordCount is True is fixed -Bug with AV failure on opening TCustomDADataSet ...
- 0000781: UniDBGrid: Row selection bug when no data is in dataset - 0000779: UniStringGrid: OnClick event implemented - 0000780: UniDBGrid: OnCellClick bug - 0000777: TUniDBGridColumn.ReadOnly ...
This is believed to be a bug in the Windows clipboard and a work around hasn't been found yet. * Asynchronous targets appears to be broken in the current release. * When TDropFileTarget....
- fixed bug when using two or more macroses in memo version 4.12 --------------- + added support of Embarcadero Rad Studio EX2 (x32/x64) + added export of Excel formulas in the BIFF export + added ...