How to disable WARN when connecting to SQL database in Java

Replace – jdbc:mysql://localhost:3306/demo

With – jdbc:mysql://localhost:3306/demo?useSSL=false


Try to use the useSSL=false in the connection string

Example:

jdbc:mysql://xxxxxxx:3306/xxxx?autoReconnect=true&useSSL=false

EDIT:

I had issue today 11/20/2019 while connecting mysql version 8.0.12 using java mysql driver (com.mysql.cj.jdbc.Driver, 8.0.18) and got following error

Exception in thread "main" java.sql.SQLNonTransientConnectionException: Public Key Retrieval is not allowed

I had to add allowPublicKeyRetrieval=true to connection string to fix the connection issue.

Updated this answer because its related issue :)

Tags:

Mysql

Java

Ssl