Search code examples
mysqljdbcconnection-stringmysql-8.0

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. I connected to my old instance using JDBC and a connection string that looked like this:

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

After upgrading to 8.0 that results in this error

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

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


Solution

  • It seems to be a bug in MySQL Connector/J. I have raised a bug report for it:

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