How to disable “Establishing SSL connection without server's identity verification is not recommended” warning when connecting to MySQL database in Java?

MySQLMySQLi DatabaseJava 8

To disable the warning while connecting to a database in Java, use the below concept −


The complete syntax is as follows −


Here is the warning message if you do not include “useSSL=false” −

Wed Feb 06 18:53:39 IST 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.

The snapshot is as follows −

If you want to avoid the above MySQL warning, use the syntax mention in the beginning.

The Java code is as follows −

import java.sql.Connection;
import java.sql.DriverManager;
public class AvoidSQLWarnDemo {
   public static void main(String[] args) {
      String JdbcURL = "jdbc:mysql://localhost:3306/mybusiness?" + "autoReconnect=true&useSSL=false";
      String Username = "root";
      String password = "123456";
      Connection con = null;
      try {
         con = DriverManager.getConnection(JdbcURL, Username, password);
         System.out.println("Your JDBC URL is as follows:" + JdbcURL);
      } catch (Exception exec) {

After running the above java program, you won’t get the warning. However, you will get the following output −

Published on 27-Feb-2019 08:14:22