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

时间:2018-04-25 12:01:31

标签: mysql jdbc connection-string mysql-8.0

我最近将我的MySQL实例从5.7升级到8.0。 我使用JDBC和一个看起来像这样的连接字符串连接到我的旧实例:

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

升级到8.0后导致此错误

com.mysql.cj.exceptions.WrongArgumentException: Malformed database URL, failed to parse the connection string near '='')'.

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

3 个答案:

答案 0 :(得分:1)

这似乎是MySQL Connector / J中的错误。我提出了一个错误报告:

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

答案 1 :(得分:1)

在JDBC连接字符串中针对MySQL 8.0尝试以下操作:

Pytest

例如

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



对于JDBC连接字符串中的MySQL 7.0:

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

例如

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

答案 2 :(得分:0)

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