Issue while creating a MySql jdbc connection

Avatar

Avatar

ramandeep

Avatar

ramandeep

ramandeep

19-06-2020

Hi everyone,

While creating a connection with external database I am getting following error in AEM;

{"jsonrpc":"2.0","id":"1592592345532","error":{"code":-32001,"message":"Could not establish connection: Could not create connection to database server. Attempted reconnect 3 times. Giving up.","data":{"exceptionTypeName":"org.apache.metamodel.MetaModelException","message":"Could not establish connection: Could not create connection to database server. Attempted reconnect 3 times. Giving up."}}}

 

FYI.., Database at localhost is working fine but while connecting database from another IP I am not able to create a connection.

Please help me to figure out the issue. I have not found any error in the logs but in the browser console I got the above mentioned error.

 

I just checked and found that the DB user I was using to connect with AEM data-source has no access to required database. Now issue has been resolved after giving database access permission to db user but only on AEM localhost but not on the AEM cloud instance. Now I am getting following error;


{"jsonrpc":"2.0","id":"1592596086498","error":{"code":-32001,"message":"Could not establish connection: Communications link failure\n\nThe last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.","data":{"exceptionTypeName":"org.apache.metamodel.MetaModelException","message":"Could not establish connection: Communications link failure\n\nThe last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server."}}}

Thanks in advance.

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar

Arun_Patidar

MVP

Total Posts

3.1K

Likes

1.2K

Correct Reply

882

Avatar

Arun_Patidar

MVP

Total Posts

3.1K

Likes

1.2K

Correct Reply

882
Arun_Patidar
MVP

20-06-2020

Communications link failure, then it means that the DB isn't reachable at all. This can have one or more of the following causes:

  1. IP address or hostname in JDBC URL is wrong.
  2. Hostname in JDBC URL is not recognized by local DNS server.
  3. Port number is missing or wrong in JDBC URL.
  4. DB server is down.
  5. DB server doesn't accept TCP/IP connections.
  6. DB server has run out of connections.
  7. Something in between Java and DB is blocking connections, e.g. a firewall or proxy.

To solve the one or the other, follow the following advices:

  1. Verify and test them with ping.
  2. Refresh DNS or use IP address in JDBC URL instead.
  3. Verify it based on my.cnf of MySQL DB.
  4. Start the DB.
  5. Verify if mysqld is started without the --skip-networking option.
  6. Restart the DB and fix your code accordingly that it closes connections in finally.
  7. Disable firewall and/or configure firewall/proxy to allow/forward the port.

 

Please check https://stackoverflow.com/questions/2983248/com-mysql-jdbc-exceptions-jdbc4-communicationsexception-...

 

Answers (2)

Answers (2)

Avatar

Avatar

Veena_Vikram

MVP

Avatar

Veena_Vikram

MVP

Veena_Vikram
MVP

22-06-2020

Agree with @Arun_Patidar In my opinion, it could be a firewall issue. 

Avatar

Avatar

vanegi

Employee

Avatar

vanegi

Employee

vanegi
Employee

20-06-2020

 Hi Ramandeep,

Are you using mysql DB? Can you check with the new mysql connector? Also, try restarting the server once.

https://mvnrepository.com/artifact/mysql/mysql-connector-java

 

Thanks,

Vaishali