Recently, when I was learning springboot + MySQL + mybatis and doing a project with CSDN boss, I encountered an error when connecting to MySQL:
java.sql.SQLException: Unknown system variable 'query_cache_size'
Error reason:
the version of MySQL connector Java is too low, and the database driver version does not match the local MySQL version. Query cache has been out of date since MySQL 5.7.20, but it has been removed since MySQL 8.0
solution:
first, modify the driver name in the application. YML
or application. Properties
file
driver-class-name: com.mysql.cj.jdbc.Driver #Linked Drivers for MySQL 8.0 onwards
com.mysql.jdbc.Driver #Older linked drivers
Then modify the driver version in the POM. XML
file
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.25</version>
<scope>runtime</scope>
</dependency>
The previous version here is 5. X. just change it to the actual MySQL version number. Mine is 8.0.25
remember to reload Maven’s dependencies after changing. Otherwise, it will still report an error:
Cannot load driver class:com.mysql.cj.jdbc.Driver
Click this icon to reload the dependency
perfect solution!
Read More:
- [Solved] Error updating database. Cause: java.sql.SQLException: Unknown initial character set index ‘255‘ re
- Error querying database.Cause: java.sql.SQLException: Error setting driver on UnpooledDataSource.
- [Solved] IDEA Error: Unknown system variable ‘tx_isolation‘ at
- [Solved] java.sql.SQLException: Unsupported character encoding ‘utf-8
- [Solved] Mybatis insert Error: Cause: java.sql.SQLException: SQL String cannot be empty
- [Solved] mybatis Error querying database. Cause: java.sql.SQLException: The server time zone value
- Java.sql.sqlexception: unable to read more data from socket
- [Solved] Error updating database. Cause: java.sql.SQLException: Incorrect integer value: ‘**‘ for column
- [Solved] java.sql.SQLException: Table ‘xxx.hibernate_sequence’ doesn’t exist
- API Failed to Connect phoenix Error: java.sql.SQLException: ERROR 726 (43M10): Inconsistent namespace mapping properties
- [Solved] IDEA jdbc Connect Database Error: java.sql.SQLException: Undefined Error
- [How to Fix]java.sql.SQLException: Incorrect string value: ‘\xF0\x9F\x98\x82\xF0\x9F…’
- JAVA Error: Error attempting to get column ‘XXX’ from result set. Cause java.sql.
- [Solved] JAVA Operate Database Error: You have an error in your SQL syntax; Dao layer SQL statement error
- How to Solve SQL comments error in the mybatis query
- [Solved] JPA query data error: Page 1 of 0 containing UNKNOWN instances
- [Solved] nacos Startup Error: Please set the JAVA_HOME variable in your environment
- Resolve warning: could’t clear Tomcat cache java.lang.NoSuchFieldException: resourceEntries
- [Solved] Initialization of anonymous inner class member variable causes java.lang.stackoverflowerror
- [How to Solve Error]java.util.Date cannot be cast to java.sql.Date