2

I am trying to connect my java code with remote MySQL database by using JDBC but I got this error message on NetBeans JDBC connection window:

Cannot establish a connection to jdbc:mysql://example.com:3306/databaseName?zeroDateTimeBehavior=convertToNull using com.mysql.jdbc.Driver (Communications link failure

The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.)

How can I solve this problem?

Maytham Fahmi
  • 31,138
  • 14
  • 118
  • 137
Noah
  • 21
  • 1
  • Just making sure, is your JDBC string actually pointing to example.com, and does it really have databaseName? Or is that hiding the true values? – Chris Forrence Feb 14 '18 at 14:43

1 Answers1

0

It is not a problem:

  1. Load driver: Class.forName.... - a lot of examples when you google it
  2. Check your credentials (url, database name, username, password)

And! It is very important: try to google and you find:

Solving a "communications link failure" with JDBC and MySQL

and this:

com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

IvanSPb
  • 193
  • 1
  • 6