Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

New MySQL driver causes java.sql.SQLNonTransientConnectionException: CLIENT_PLUGIN_AUTH is required

Tags:

java

mysql

ssl

jdbc

If change MySQL JDBC driver from 5.1.38 to 6.0.2 I get the following exception

java.sql.SQLNonTransientConnectionException: CLIENT_PLUGIN_AUTH is required

This exception was happened in normal JDBC initilization.

Probably, this can be related with SSL, since I get the following messages also

Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.

which were absent in previous version.

like image 563
Dims Avatar asked May 20 '16 13:05

Dims


People also ask

How do I fix Java SQL Sqlception no suitable driver found for JDBC?

This error occurs if JDBC is not able to find a suitable driver for the URL format passed to the getConnection() method e.g. "jdbc:mysql://" in our case. In order to solve this error, you need the MySQL JDBC driver like mysql-connector-java-5.1. 36. jar in your classpath.

How do I know if MySQL JDBC driver is installed?

You can determine the version of the JDBC driver that you installed, by calling the getDriverVersion method of the OracleDatabaseMetaData class. You can also determine the version of the JDBC driver by executing the following commands: java -jar ojdbc5. jar.


4 Answers

    Use Maven depandency 
###pom.xml  
           <dependency>
                <groupId>mysql</groupId>
                <artifactId>mysql-connector-java</artifactId>
                <version>5.1.37</version>
            </dependency>

##application.properties

server.port=9092
jwt.secret=javainuse
spring.datasource.url=jdbc:mysql://localhost:3306/hospital
spring.datasource.username=root
spring.datasource.password=root
spring.datasource.driver-class-name= com.mysql.jdbc.Driver
spring.datasource.platform=mysql
#spring.jpa.hibernate.ddl-auto=create-drop

spring.jpa.properties.hibernate.dialect= org.hibernate.dialect.MySQL5InnoDBDialect
spring.jpa.hibernate.ddl-auto= update

#spring.jpa.properties.hibernate.dialect= org.hibernate.dialect.MySQL5InnoDBDialect
like image 140
Avinash Khadsan Avatar answered Oct 12 '22 23:10

Avinash Khadsan


It seems new versions of mysql connector (from 6 on) are not compatible with old version of the DBMS mysql(below 5.6). So in order to solve your problem, if you make an update of mysql connector, try to do the same with the DBMS. Actually I had the same issu with mysql connector 8.0.13 and the DBMS msql 5.1.... I solved it by moving the DBMS to 5.6.17

like image 39
Vivien SA'A Avatar answered Oct 13 '22 00:10

Vivien SA'A


It may be due to mysql version is too old so you need to do 3 changes in that case: in application.properties do first 2 changes:

  1. spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5Dialect

  2. spring.datasource.driver-class-name=com.mysql.jdbc.Driver

  3. Do changes in pom.xml file in dependency of mysql-connector-java replace scope tag to the version tag and in version write your mysql version like 5.1

like image 37
Tushar Mittal Avatar answered Oct 13 '22 00:10

Tushar Mittal


I had the same issue and I resolved by changing the parent tag version from 2.1.1.RELEASE to 2.0.0.RELEASE

from

<parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.1.1.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>

to

<parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.0.0.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
like image 28
Merwais Muafaq Avatar answered Oct 12 '22 23:10

Merwais Muafaq