log4jdbc solves the problem of sql parameters and causes The new driver class is `com.mysql.cj.jdbc.Driver'

Reference article : Portal
and the problem I encountered was that the console reported a series of errors:
Loading class com.mysql.jdbc.Driver'. This is deprecated. The new driver class is com.mysql.cj.jdbc.Driver'. The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary.
Of course, this does not affect the operation. I checked for a long time and in the end it was caused by the loaded driver, and I tried the following:

 url: jdbc:log4jdbc:mysql://xxx:xxx/xxx?useUnicode=true&characterEncoding=utf-8&serverTimezone=CTT
 username: 
 password: 
 max-active: 5
 driver-class: com.mysql.cj.jdbc.Driver

Still can't solve it, and finally found out that it was added: the log4jdbc problem caused by removing it will not have this problem.
The place to print is the Driver under jdc under the mysql package

public class Driver extends com.mysql.cj.jdbc.Driver {
    
    
    public Driver() throws SQLException {
    
    
        super();
    }

    static {
    
    
        System.err.println("Loading class `com.mysql.jdbc.Driver'. This is deprecated. The new driver class is `com.mysql.cj.jdbc.Driver'. "
                + "The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary.");
    }
}

I found the reason but didn't solve it~~~, if there is a problem, just remove the dependency and prevent him from printing and completing the sql

		<dependency>
            <groupId>com.googlecode.log4jdbc</groupId>
            <artifactId>log4jdbc</artifactId>
            <version>1.2</version>
        </dependency>

Also remove: log4jdbc from the url splicing of the yml file. I added this mainly to let him print the complete sql parameters for log analysis. see you later

Guess you like

Origin blog.csdn.net/qq_43566782/article/details/129285442