简体   繁体   中英

java.sql.SQLException: Unknown system variable 'tx_isolation'

I am using play framework and I want to connect db, but I can't because I am getting following error:

play.api.Configuration$$anon$1: Configuration error[Cannot connect to database [default]]
Caused by: play.api.Configuration$$anon$1: Configuration error[Failed to initialize pool: Unknown system variable 'tx_isolation']
Caused by: com.zaxxer.hikari.pool.HikariPool$PoolInitializationException: Failed to initialize pool: Unknown system variable 'tx_isolation' java.sql.SQLException: Unknown system variable 'tx_isolation

I tried to find tx_isolation , but it doesn't exist:

mysql> show variables like 'tx_isolation';
Empty set (0.00 sec)

So what is and how can I find tx_isolation ?


Sorry. this is my error code. and I use mysql 8.0.11. so i find 'transaction_isolation'

play.db {
  config = "db"
  default = "default"
}
db {
//TODO : 작업필요
  default.driver = com.mysql.jdbc.Driver
  default.url = "jdbc:mysql://127.0.0.1:3306/testPlayDB"
  default.username = root
  default.password = "321A@654"
}

Error cause Default.url = "jdbc:mysql://127.0.0.1:3306/testPlayDB"

i use Scala, playframework and StackOverflow first time...

Thank you.

If you are using MYSQL8, try to show variables like 'transaction_isolation' . Mysql8 has renamed tx_isolation to transaction_isolation .

I had a same problem. I upgraded my MySql Connector and solved my issue. try to use version 8 , like this:

<!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
<dependency>
    <groupId>mysql</groupId>
    <artifactId>mysql-connector-java</artifactId>
    <version>8.0.13</version>
</dependency>

我也遇到了同样的错误(当我在 mysql5 中使用 mysql6 数据库时它工作正常)然后我将连接器 jar 从mysql-connector-java-5.1.46.jarmysql.jar然后问题消失了。

You have a mismatch between client lib version and server version.

Here are the version numbers where things change:

mysql-connector-java-8.0.8 release notes

Important Change: Following the changes in MySQL Server 8.0.3, the system variables tx_isolation and tx_read_only have been replaced with transaction_isolation and transaction_read_only in the code of Connector/J. Users should update Connector/J to this latest release in order to connect to MySQL 8.0.3. They should also make the same adjustments to their own applications if they use the old variables in their codes. (Bug #26440544)

mysql server 5.7.20 release notes

Previously, the --transaction-isolation and --transaction-read-only server startup options corresponded to the tx_isolation and tx_read_only system variables. For better name correspondence between startup option and system variable names, transaction_isolation and transaction_read_only have been created as aliases for tx_isolation and tx_read_only. The tx_isolation and tx_read_only variables are now deprecated and will be removed in MySQL 8.0. Applications should be adjusted to use transaction_isolation and transaction_read_only instead.

mysql server 8.0.3 release notes

The deprecated tx_isolation and tx_read_only system variables have been removed. Use transaction_isolation and transaction_read_only instead.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM