• Register
0 votes
138 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

Please log in or register to answer this question.

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 364 views
364 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
1 vote
1 answer 211 views
211 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, 2020 stewart 4k points
0 votes
1 answer 363 views
363 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 377 views
377 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 227 views
227 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
0 votes
1 answer 43 views
43 views
Problem: I am trying to consume a PHP webservice which has the SSL certificate. I have the .net 3.5 Class library it references the webservice with a 'Add Service references' in Visualstudio 2010 If I try calling the main method of my webservice then I ... SslPolicyErrors sslPolicyErrors) { return true; } But somehow it is not working. Also I have already a certificate installed on my own pc.
asked Aug 12, 2020 Raphael Pacheco 4.9k points
0 votes
1 answer 1.5K views
1.5K views
Problem : I am using the Hibernate for a first time for my project and I am very new to Hibernate. I think I have followed all the instructions written in some tutorials but still I keep getting the below Exception that is in my title: Exception in thread "main" ... should just change a connection.pool_size property, but if I do so it guesses that I only will get more errors. Can anyone help me?
asked Jan 30, 2020 jwilliam 3.9k points
0 votes
1 answer 320 views
320 views
Problem : I am facing following error while executing script cannot insert explicit value for identity column in table when identity_insert is set to off.
asked Nov 15, 2019 peterlaw 6.9k points