Noobcoder Noobcoder - 10 months ago 50
MySQL Question

Remove output message when connecting to MySQL via Java

I have a question regarding connecting my Java program to my Mysql database.
I watched a video which creates a method that can connect to my database and has the form:

enter code here

public static Connection getConnection() throws Exception{
String driver = "....";
String url = "....";
String username ="....";
String password = "....";

Connection conn = DriverManager.getConnection(url,username,password);
return conn;
catch(Exception e){System.out.println("Connection failed ");}
return null;

When executing this method in each function (such as deleting an entry or adding), I always receive the message: "Sat Nov 05 12:04:49 CET 2016 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."

How can I stop this error message and fix the above problem? Even though this message is shown, I can still work with the database, however, I want to get rid of the message because it harms the User interface (looks ugly and always gets repeated each time I connect to the database).

I know little about eclipse and MySQL. As a result, I don't know the terms use above.

Could anyone aid me on what to do in order to hide or remove the above message?

Thanks :)

Answer Source

This problem comes when you are trying to make SSL connection with the databse and you can avoid this warning by using the connection url:


You can refer here for mysql jdbc connection properties.