*是我隱藏了相關資料
public class DbUtil {
public static final String URL = "jdbc:mysql://*.*.*.*:*/test?useUnicode=true&characterEncoding=utf-8&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC";
public static final String USER = "*";
public static final String PASSWORD = "*";
public static void main(String[] args) throws Exception {
Class.forName("com.mysql.cj.jdbc.Driver");
Connection conn = DriverManager.getConnection(URL, USER, PASSWORD);
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("SELECT * FROM user");
while (rs.next()) {
System.out.println(rs.getString("id") + " name:" + rs.getInt("name"));
}
}
}
pom
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>test</groupId>
<artifactId>test</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.20</version>
</dependency>
</dependencies>
</project>
資料庫版本為
mysql> select version();
+-----------+
| version() |
+-----------+
| 8.0.20 |
+-----------+
1 row in set (0.37 sec)
mysql>
運行居然報錯
Exception in thread "main" java.sql.SQLException: Unknown system variable 'query_cache_size'
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:129)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97)
uj5u.com熱心網友回復:
1. mysql-connecter-java的版本過低,很顯然是資料庫驅動程式與資料庫版本不對應2. query cache 在Mysql 8.0之后就被移除了
uj5u.com熱心網友回復:
你答的并不正確,看引入的驅動便可知
uj5u.com熱心網友回復:
初步猜測原因可能是mysql使用了proxysql導致的?轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/14976.html
標籤:MySQL
上一篇:求解!!!
下一篇:如何知道資料庫中哪些表沒有記錄
