• Register
0 votes
189 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 624 views
624 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 5 views
5 views
Problem: What’s wrong here > column not found: 1054 unknown column
asked Mar 20 Azlan2020 2.3k points
0 votes
1 answer 5 views
5 views
Problem: I'm having problems during my learning as I mentioned in my question above, I try to find on web search but I can't get proper information, can you help me to continue my project?
asked Mar 21 shamimkhan 15.1k points
0 votes
1 answer 8 views
8 views
PROBLEM : Someone help me to fix this Please on > 'curl: (35) unknown ssl protocol error in connection' ?
asked Mar 16 Samiur1 38.4k points
1 vote
1 answer 4 views
4 views
Problem: Any ideas on what I need to do to fix this? unrecognized ssl message, plaintext connection?
asked Mar 15 MUHAMMAD MUNEEB 83k points
0 votes
1 answer 3 views
3 views
Problem: Please help me to solve it out : javax net ssl sslhandshakeexception received fatal alert handshake_failure
asked Apr 7 rakib1 51.5k points
0 votes
0 answers 1 view
1 view
Problem: What are my options for resolving this problem? javax.net.ssl.sslhandshakeexception: received fatal alert: handshake_failure
asked Apr 7 rakib1 51.5k points
0 votes
1 answer 3 views
3 views
Problrem: how to install ssl certificate in tomcat 7
asked Apr 6 Ifra 24.4k points
0 votes
1 answer 455 views
455 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