Record the problems encountered in the learning process of Java mybatis framework
1. An exception occurred while building the first mybatis project:
Exception in thread "main" org.apache.ibatis.exceptions.PersistenceException:
Error querying database. Cause: java.sql.SQLException: Error setting driver on UnpooledDataSource.
Cause: java.lang.ClassNotFoundException: Cannot find class: com.mysql.cj.jdbc.Driver
Solution: the MySQL connector Java driver version is used incorrectly
I use MySQL version 8.0.22
import the driver of version 5.1.23, and the dependency declared in pom.xml file is
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.23</version>
</dependency>
The two versions do not correspond, so the driver error cannot be found.
the solution is to download the driver of version relative to, that is, the driver of version 8.0.22. The official website address is version 8.0.22
and then change the dependency in the POM file to:
<!--MySQL-->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.22</version>
</dependency>
Another point is that the POM file should include not only driver dependencies, but also mybatis dependencies
<!--mybatis-->
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
<version>3.4.5</version>
</dependency>
Read More:
- [Solved] mybatis Error querying database. Cause: java.sql.SQLException: The server time zone value
- [Solved] Error setting driver on UnpooledDataSource. Cause: java.lang.ClassNotFoundException: Cannot find cla
- Error querying database. Cause: java.sql.SQLSyntaxErrorException: Expression #2 of SELECT list is no
- [Solved] Error updating database. Cause: java.sql.SQLException: Incorrect integer value: ‘**‘ for column
- [Solved] java.sql.SQLException: Unknown system variable cache query size
- [Solved] Error updating database. Cause: java.sql.SQLException: Unknown initial character set index ‘255‘ re
- [Solved] IDEA jdbc Connect Database Error: java.sql.SQLException: Undefined Error
- [Solved] java.sql.SQLException: Unsupported character encoding ‘utf-8
- [Solved] Mybatis insert Error: Cause: java.sql.SQLException: SQL String cannot be empty
- [Solved] Spring jdbctemplate Error: ‘Java. SQL. Driver’ for property ‘driver’: no
- Java.sql.sqlexception: unable to read more data from socket
- [Solved] JAVA Operate Database Error: You have an error in your SQL syntax; Dao layer SQL statement error
- [Solved] java.sql.SQLException: Table ‘xxx.hibernate_sequence’ doesn’t exist
- [How to Fix]java.sql.SQLException: Incorrect string value: ‘\xF0\x9F\x98\x82\xF0\x9F…’
- API Failed to Connect phoenix Error: java.sql.SQLException: ERROR 726 (43M10): Inconsistent namespace mapping properties
- JAVA Error: Error attempting to get column ‘XXX’ from result set. Cause java.sql.
- [Solved] Tomcat Server Error: java.lang.NullPointerException Csonsole Error ClassNotFoundException: com.mysql.jdbc.Driver
- [Solved] ssm Error: Error querying database. Cause: org.apache.ibatis.executor.ExecutorException: Executor was closed
- Java database Druid error: com.alibaba.druid.pool.DruidDataSource error
- [How to Solve Error]java.util.Date cannot be cast to java.sql.Date