Environmental Science:
JDK1.7
mysql-connector-java 8.0.16
C3p0 configuration file
Error message:
Incompatibility between the JDK version and the jdbc driver
java.lang.unsupported classversionerror
Exception in thread "com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#2"
java.lang.UnsupportedClassVersionError: com/mysql/cj/jdbc/Driver :
Unsupported major.minor version 52.0
Solve the problem: change the JDK to 1.8, restart, or report an error. Replace the configuration information of the URL successfully. Details are as follows:
Connect to the database using a profile
Create c3p0-config.xml in the SRC folder. The name and address cannot be changed
Profile code, note & amp; To escape to & amp; amp
<c3p0-config>
<default-config>
<property name="driverClass">com.mysql.cj.jdbc.Driver</property>
<property name="jdbcUrl">jdbc:mysql://localhost:3306/webdemo?useSSL=false&serverTimezone=UTC</property>
<property name="user">root</property>
<property name="password">root</property>
<property name="initialPoolSize">10</property>
<property name="maxIdleTime">30</property>
<property name="maxPoolSize">100</property>
<property name="minPoolSize">10</property>
<property name="maxStatements">200</property>
</default-config>
</c3p0-config>
Test code
package cn.wahll.test;
import com.mchange.v2.c3p0.ComboPooledDataSource;
import org.junit.Test;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
public class c3p0Demo {
@Test
public void c3p0PoolTest() throws Exception {
//Find the default configuration directly under the configuration file
ComboPooledDataSource dataSource = new ComboPooledDataSource();
Connection conn = dataSource.getConnection();
String sql = "INSERT INTO category VALUES('bsafvb','asdgg')";
PreparedStatement preparedStatement = conn.prepareStatement(sql);
preparedStatement.executeUpdate();
}
}
Read More:
- How to Solve can‘t connect to local mysql server through socket ‘/var/lib/mysql/mysql.sock‘
- host ‘‘ is not allowed to connect to this mysql server Connect MYSQL Error
- How to Fix MySQL ERROR 1130 (HY000): Host ‘XXXX’ is not allowed to connect to this MySQL server
- C# Connect MYSQL Error: MySql.Data.MySqlClient.MySqlException:“SSL Connection error.”
- MySql Install Error: Can‘t connect to local MySQL server through socket ‘/tmp/mysql.sock‘
- [Solved] ERROR 2002 (HY000): Can’t connect to local MySQL server through socket’/var/lib/mysql/mysql.sock’ (2)
- How to Solve MYSQL Error: Failed to start MySQL 8.0 database server
- [Solved] MYSQL Command Execute Error: Can ‘t connect to local MySQL server through socket ‘/tmp/mysql.sock ‘(2) “
- Remote connection to MySQL database error: is not allowed to connect to this MYSQL server solution
- Mysql Flashback Warning: C:\Program Files\MySQL\MySQL Server 8.0\bin\mysql.exe
- ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock’
- Docker: How to Solve MYSQL8 & Navicat remote connection error
- Using Mybatis to connect to the database error: Loading class `com.mysql.jdbc.Driver‘. This is deprecated. The new driver···
- MySQL Install Error: MySQL error 1042: Unable to connect to any of the specified MySQL hosts
- MYSQL Enter password:ERROR 2003 (HY000): Can‘t connect to MySQL server on ‘localhost:3306‘
- How to Solve mysql [Err] 1067-Invalid default value for
- How to Solve Mysql8 load data error
- How to Solve MYSQL into outfile Error13
- How to Solve MYSQL Error: No module named MySQLdb
- How to Solve MYSQL ERROR: relation “table_name” does not exist