Which JDBC driver is recommended for TiDB?

This topic has been translated from a Chinese forum by GPT and might contain errors.

Original topic: tidb推荐的jdbc驱动选哪个呢

| username: Billmay表妹

Hello everyone, which JDBC driver is recommended for TiDB? I see in the documentation (选择驱动或 ORM 框架 | PingCAP 文档中心) that one recommended option is the last version of MySQL 5.1, which is 5.1.49, and the other is using TiDB-JDBC (GitHub - pingcap/mysql-connector-j: MySQL Connector/J, this library seems to have not been updated for a long time). Which of these two drivers is better to choose??

| username: Billmay表妹 | Original post link

Reply from @数据小黑:

If there are no special requirements, it is recommended to use the last version of JDBC 5.1, which is 5.1.49. If there are feature requirements that necessitate using 8.0.29, it is recommended to use TiDB-JDBC instead of the original 8.0.29. If client support for SM (Chinese cryptographic algorithms) is needed, only TiDB-JDBC can be used.

| username: 数据小黑 | Original post link

The question includes this link: 选择驱动或 ORM 框架 | PingCAP 文档中心
It is actually an official explanation that mentions several obvious differences:
It is strongly recommended to use the last version of JDBC 5.1, which is 5.1.49. This is because the current version 8.0.29 has an unmerged bug fix that may cause thread deadlock when used with TiDB. Until this fix is merged into MySQL JDBC 8.0, it is advised not to upgrade to version 8.0.
TiDB-JDBC is a customized version based on MySQL 8.0.29. TiDB-JDBC is compiled based on the official MySQL 8.0.29 version, fixing the original JDBC errors in prepare mode with multiple parameters and multiple fields EOF, and adding features such as TiCDC snapshot auto-maintenance and SM3 authentication plugin.
Authentication based on SM3 is only supported in the TiDB version of MySQL Connector/J.

| username: Raymond | Original post link

So, does that mean all current versions of TiDB, including versions above 6.1, are recommended to use JDBC 5.1.49?

| username: 张雨齐0720 | Original post link

It should be that the current implementation of TiDB Server should be fully compatible with 5.1.49.
That’s what they recommended.