Arraying Arraying - 1 year ago 353
Java Question

JDBC Connection Error With Maven

I have a problem connecting to a database with JDBC. I get the following error upon connecting:


Here is my code:

private void connect() {
try {
connection = DriverManager.getConnection("jdbc:mysql://"+url+":"+port+"/"+database, username, password);
catch(Exception e) {

Is my connection string wrong? This is what I added to my Maven dependencies:


I use this code (with different messages) in another project that does not use Maven, and it works fine. The credentials work. I've attempted to add
but it doesn't change the result.

Zia Zia
Answer Source

Replace your URL with the below and try it

jdbc:mysql://"+url+":"+port+"/"+database?autoReconnect=true&useSSL=false, username, password

This is related to SSL.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download