Bug #116120 Inappropriate charset selected for connection when jdk.charsets not included
| Submitted: | 16 Sep 2024 12:02 | Modified: | 8 Jul 2025 1:10 |
|---|---|---|---|
| Reporter: | Martin Sandiford | Email Updates: | |
| Status: | Closed | Impact on me: | |
| Category: | Connector / J | Severity: | S2 (Serious) |
| Version: | 9.0.0 | OS: | Any |
| Assigned to: | CPU Architecture: | Any |
[16 Sep 2024 12:02]
Martin Sandiford
[18 Sep 2024 9:09]
MySQL Verification Team
Hello Martin Sandiford, Thank you for the report and test case. I quickly ran your test case but seeing results as expected. Am I missing anything? Do I need to set charsets etc at the server level etc.? Please let me know. -- locale LANG=en_US.UTF-8 LC_CTYPE="en_US.UTF-8" LC_NUMERIC="en_US.UTF-8" LC_TIME="en_US.UTF-8" LC_COLLATE="en_US.UTF-8" LC_MONETARY="en_US.UTF-8" LC_MESSAGES="en_US.UTF-8" LC_PAPER="en_US.UTF-8" LC_NAME="en_US.UTF-8" LC_ADDRESS="en_US.UTF-8" LC_TELEPHONE="en_US.UTF-8" LC_MEASUREMENT="en_US.UTF-8" LC_IDENTIFICATION="en_US.UTF-8" LC_ALL= -- -- MySQL Server 8.0.39 BugNumber=116134 rm -rf $BugNumber/ bin/mysqld --no-defaults --initialize-insecure --basedir=$PWD --datadir=$PWD/$BugNumber --log-error-verbosity=3 bin/mysqld_safe --no-defaults --mysqld-version='' --basedir=$PWD --datadir=$PWD/$BugNumber --core-file --socket=/tmp/mysql.sock --port=3306 --log-error=$PWD/$BugNumber/log.err --mysqlx-port=33330 --mysqlx-socket=/tmp/mysql_x_ushastry.sock --log-error-verbosity=3 --secure-file-priv="" --local-infile=1 2>&1 & bin/mysql -uroot -S/tmp/mysql.sock Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 11 Server version: 8.0.39 MySQL Community Server - GPL Copyright (c) 2000, 2024, Oracle and/or its affiliates. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> show variables like '%version%'; +--------------------------+------------------------------+ | Variable_name | Value | +--------------------------+------------------------------+ | admin_tls_version | TLSv1.2,TLSv1.3 | | immediate_server_version | 999999 | | innodb_version | 8.0.39 | | original_server_version | 999999 | | protocol_version | 10 | | replica_type_conversions | | | slave_type_conversions | | | tls_version | TLSv1.2,TLSv1.3 | | version | 8.0.39 | | version_comment | MySQL Community Server - GPL | | version_compile_machine | x86_64 | | version_compile_os | Linux | | version_compile_zlib | 1.2.13 | +--------------------------+------------------------------+ 13 rows in set (0.01 sec) mysql> -- javac -cp .:mysql-connector-j-9.0.0/mysql-connector-j-9.0.0.jar Bug116120.java rm -rf output && jlink --add-modules "java.base,java.sql,java.naming" --output output java -cp .:mysql-connector-j-9.0.0/mysql-connector-j-9.0.0.jar Bug116120 Java: 17.0.12+8-LTS-286 Connection: jdbc:mysql://******/mysql?useUnicode=true&characterEncoding=UTF-8&useSSL=false&allowPublicKeyRetrieval=true Query: SELECT @@character_set_connection, @@collation_connection @@character_set_connection: utf8mb4 @@collation_connection: utf8mb4_0900_ai_ci regards, Umesh
[19 Sep 2024 10:34]
Martin Sandiford
Hi Umesh, It looks like you have run the test with the system "java", rather than the java that jlink places in the output/bin folder. You will need to use the ./output/bin/java executable to launch the test. I don't think this is the only issue though— I just tried on Linux (Ubuntu 20.4), and the test seems to be unreproducible with JDK 17 there. I also tried with JDK 21, and can reproduce the problem with that— if you are using Linux, you will need to use JDK 21. Previously I had been using MacOS, and it's present with both JDK 17 & 21 on that platform. I've also just tried with server 8.0.39 that you are using and can reproduce the issue with that.
[19 Sep 2024 11:33]
MySQL Verification Team
Thank you, Martin. Let me re-run and get back to you if anything further needed. Sincerely, Umesh
[19 Sep 2024 12:07]
MySQL Verification Team
Thank you Martin. I'm able to reproduce now. regards, Umesh
[19 Sep 2024 12:12]
MySQL Verification Team
-- -- Env cat /etc/*release Oracle Linux Server release 7.9 NAME="Oracle Linux Server" VERSION="7.9" ID="ol" ID_LIKE="fedora" VARIANT="Server" VARIANT_ID="server" VERSION_ID="7.9" PRETTY_NAME="Oracle Linux Server 7.9" ANSI_COLOR="0;31" CPE_NAME="cpe:/o:oracle:linux:7:9:server" HOME_URL="https://linux.oracle.com/" BUG_REPORT_URL="https://bugzilla.oracle.com/" ORACLE_BUGZILLA_PRODUCT="Oracle Linux 7" ORACLE_BUGZILLA_PRODUCT_VERSION=7.9 ORACLE_SUPPORT_PRODUCT="Oracle Linux" ORACLE_SUPPORT_PRODUCT_VERSION=7.9 Red Hat Enterprise Linux Server release 7.9 (Maipo) Oracle Linux Server release 7.9 -- jdk 17 javac -cp .:mysql-connector-j-9.0.0/mysql-connector-j-9.0.0.jar Bug116120.java rm -rf output && jlink --add-modules "java.base,java.sql,java.naming" --output output output/bin/java -cp .:mysql-connector-j-9.0.0/mysql-connector-j-9.0.0.jar Bug116120 Java: 17.0.12+8-LTS-286 Connection: jdbc:mysql://******/mysql?useUnicode=true&characterEncoding=UTF-8&useSSL=false&allowPublicKeyRetrieval=true Query: SELECT @@character_set_connection, @@collation_connection @@character_set_connection: utf8mb4 @@collation_connection: utf8mb4_0900_ai_ci -- jdk 21 javac -cp .:mysql-connector-j-9.0.0/mysql-connector-j-9.0.0.jar Bug116120.java rm -rf output && jlink --add-modules "java.base,java.sql,java.naming" --output output output/bin/java -cp .:mysql-connector-j-9.0.0/mysql-connector-j-9.0.0.jar Bug116120 Java: 21.0.4+8-LTS-274 Connection: jdbc:mysql://******/mysql?useUnicode=true&characterEncoding=UTF-8&useSSL=false&allowPublicKeyRetrieval=true Query: SELECT @@character_set_connection, @@collation_connection @@character_set_connection: eucjpms @@collation_connection: eucjpms_japanese_ci -- jdk 23 javac -cp .:mysql-connector-j-9.0.0/mysql-connector-j-9.0.0.jar Bug116120.java rm -rf output && jlink --add-modules "java.base,java.sql,java.naming" --output output output/bin/java -cp .:mysql-connector-j-9.0.0/mysql-connector-j-9.0.0.jar Bug116120 Java: 23+37-2369 Connection: jdbc:mysql://******/mysql?useUnicode=true&characterEncoding=UTF-8&useSSL=false&allowPublicKeyRetrieval=true Query: SELECT @@character_set_connection, @@collation_connection @@character_set_connection: eucjpms @@collation_connection: eucjpms_japanese_ci
[8 Jul 2025 1:10]
Daniel So
Posted by developer: Added the following entry to the Connector/J 9.4.0 changelog: "If java.charsets was not loaded into the JVM, Connector/J mapped UTF-8 connections to the MySQL eucjpms characterset. This fix corrected the internal character set mapping priority, so that utf8mb4 is selected in such scenarios."
[16 Jul 2025 18:17]
Daniel So
Posted by developer: Updated the changelog entry to the following: "If jdk.charsets was not loaded into the JVM, Connector/J mapped UTF-8 connections to the MySQL eucjpms characterset. This fix corrected the internal character set mapping priority, so that utf8mb4 is selected in such scenarios."
[18 Jul 2025 20:31]
Daniel So
Posted by developer: Updated the changelog entry to the following: "If the jdk.charsets module was not loaded into the JVM, Connector/J mapped UTF-8 connections to the MySQL eucjpms characterset. This fix corrected the internal character set mapping priority, so that utf8mb4 is selected in such scenarios."
Portions of this website are copyright © 2001, 2002 The PHP Group
Page generated in 0.048 sec. using MySQL 8.4.7-u6-cloud
Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the
respective copyright holders.
It is not reviewed in advance
by Oracle and does not necessarily represent the opinion of
Oracle or any other party.