• Register
0 votes
86 views

Problem :

With my two classes I want to connect to the MySQL database. But, I always get below error:

Wed Dec 04 10:46:52 CET 2019 WARN: 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.

This is MyTestDatabase class with the main method:

public class MyTestDatabase {
    public static void main(String[] args) {
        Database mydb = new Database();
        try {
            mydb.connect();
        } catch (Exception e) {
            e.printStackTrace();
        }
        mydb.close();
    }
}

This is the MyDatabase class:

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public class MyDatabase {
    private Connection conn;
    public void connect() throws Exception{
        if(conn != null) return;
        try {
            Class.forName("com.mysql.jdbc.Driver");
        } catch (ClassNotFoundException e) {
            throw new Exception("No database found");
        }
        String connectionURL = "jdbc:mysql://localhost:3303/Peoples";
        conn = DriverManager.getConnection(connectionURL, "root", "people23");        
    }
    public void close(){
        if(conn != null){
            try {
                conn.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
    }
}
6 5 3
7,540 points

1 Answer

0 votes

Solution :

The solution is very straightforward your connection URL should look like the following one:

jdbc:mysql://localhost:3303/Peoples?autoReconnect=true&useSSL=false

This will help you indisabling the SSL and will also suppress the SSL errors.

9 7 4
38,600 points

Related questions

0 votes
1 answer 241 views
241 views
Problem : I have a java complied package and it is sopposed to communicate with https server on net. But when i try running the compilation gives the following exception: javax.net.ssl.sslexception: unrecognized ssl message, plaintext connection?
asked Oct 23, 2019 peterlaw 6.9k points
0 votes
1 answer 240 views
240 views
Problem : I am trying to call an SSL protected web service running on JDK7 based client, but getting bellow error javax.net.ssl.sslexception received fatal alert unexpected_message
asked Nov 5, 2019 peterlaw 6.9k points
0 votes
2 answers 316 views
316 views
Problem : Has anyone faced this error before? I am new to SSL javax.net.ssl.sslexception: received fatal alert: protocol_version
asked Nov 2, 2019 peterlaw 6.9k points
0 votes
3 answers 188 views
188 views
Problem : I am trying to setup a SSL Socket connection. But i am getting below error javax.net.ssl.sslhandshakeexception received fatal alert bad_certificate
asked Oct 23, 2019 peterlaw 6.9k points