MySQL Connectivity Common Errors
In this post, I'll discuss some of the common errors being encountered during connection with MySQL Server and the best possible solution worked for me or someone-
Problem-1
JDBC Connection Failure
java.sql.SQLNonTransientConnectionException: Could not create connection to database server. Attempted to reconnect 3 times. Giving up
Solution
Change JDBC url to include character encoding-
jdbc:mysql://localhost:3306/databaseName?useUnicode=true&characterEncoding=utf8&useSSL=false&useLegacyDatetimeCode=false&noAccessToProcedureBodies=true&serverTimezone=UTC
Problem-2
Connection Java-MySql: Public Key Retrieval is not allowed
Exception in thread "main" java.sql.SQLNonTransientConnectionException: Public Key Retrieval is not allowed
Solution
Change JDBC URL to include alllow Public Key Retrival true-
jdbc:mysql://localhost:3306/databaseName?allowPublicKeyRetrieval=true&useSSL=false;
Ref- https://mysqlconnector.net/connection-options/
Comments
Post a Comment