How to Solve c3p0 connect mysql8.0 Error

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&amp;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: