• Register
0 votes
64 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();
            }
        }
    }
}
7.5k 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.

36.1k points

Related questions

0 votes
1 answer 185 views
185 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 171 views
171 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 274 views
274 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 157 views
157 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
1 vote
1 answer 38 views
38 views
Problem : I am beginner to Python. Currently if I try to use the request module to have the urls text then I often face below Error: Traceback (most recent call last):  File "/usr/local/lib/python3.6/site-packages/requests-2.18.1-py3.5.egg/requests/adapters.py" ... to get the url's text to parse it. Please find below my line of code for your reference: mytext = requests.get(detail_path).mytext
asked May 2 stewart 4k points