简体   繁体   English

如何在 MySQL 8 的 JDBC 连接字符串中设置 SQL 模式?

[英]How do I set SQL mode in the JDBC connection string for MySQL 8?

I recently upgraded my MySQL instance from 5.7 to 8.0.我最近将我的 MySQL 实例从 5.7 升级到了 8.0。 I connected to my old instance using JDBC and a connection string that looked like this:我使用 JDBC 和一个如下所示的连接字符串连接到我的旧实例:

jdbc:mysql://[host:port]/[database]/?sessionVariables=sql_mode=''

It seems to be a bug in MySQL Connector/J.这似乎是 MySQL Connector/J 中的一个错误。 I have raised a bug report for it:我为它提出了一个错误报告:

https://bugs.mysql.com/bug.php?id=92485 https://bugs.mysql.com/bug.php?id=92485

Try this for MySQL 8.0 in your JDBC connection string:在 JDBC 连接字符串中为 MySQL 8.0 试试这个:

jdbc:mysql://[host:port]/[database]/?sessionVariables=&&sql_mode=''

eg例如

jdbc:mysql://localhost:3306/dbName?sessionVariables=&&sql_mode=''



For MySQL 7.0 in your JDBC connection string:对于 JDBC 连接字符串中的 MySQL 7.0:

jdbc:mysql://[host:port]/[database]/?sessionVariables=sql_mode=''

eg例如

jdbc:mysql://localhost:3306/dbName?sessionVariables=sql_mode=''

我认为这可能是因为 sql_mode 中没有任何内容。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在JetBrains DataGrip中的MySQL连接上设置SQL模式 - How to set the SQL Mode on a MySQL connection in JetBrains DataGrip 如何在 MySQL JDBC 驱动程序上设置连接超时? - How to set a connection timeout on the MySQL JDBC driver? 如何使用SSL设置MySql JDBC连接 - How to set up mySql JDBC connection with SSL 如何减轻连接com.mysql.jdbc.JDBC4Connection@11d08960触发的连接泄漏, - How do I mitigate Connection leak triggered for connection com.mysql.jdbc.JDBC4Connection@11d08960, 如何使用jdbc将数据插入到MySQL数据库的SET列中? - How do I insert data into a SET column for a mysql database with jdbc? 如何在不使用对话框的情况下为C#项目中的MySQL数据库设置连接字符串? - How do I set up a connection string for a MySQL database in a C# project without using dialog boxes? MySQL JDBC驱动程序连接字符串? - MySQL JDBC driver connection string? 如何在不设置sql模式的情况下在mysql中与group by聚合? - How do I aggregate with group by in mysql withou setting sql mode? 如何在 mysql 中找到字符串类型列的模式? - How do I find mode of a column of type string in mysql? 如何在mysql jdbc连接字符串中转义特殊字符 - how to escape special characters in mysql jdbc connection string
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM