Issue while creating a MySql jdbc connection | Community
Skip to main content
June 19, 2020
Solved

Issue while creating a MySql jdbc connection

  • June 19, 2020
  • 4 replies
  • 5407 views

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.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by arunpatidar

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-communications-link-fai

 

4 replies

ramandeepAuthor
June 19, 2020
I just checked and found that the DB user I was using to connect with AEM data-source has not access to required database. Now issue has been resolved at localhost but not on AEM cloud instance after giving database access permission to db user.
vanegi
Adobe Employee
Adobe Employee
June 20, 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

arunpatidar
Community Advisor
arunpatidarCommunity AdvisorAccepted solution
Community Advisor
June 20, 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-communications-link-fai

 

Arun Patidar
ramandeepAuthor
June 23, 2020
Thank you @1464355.
VeenaVikraman
Community Advisor
Community Advisor
June 22, 2020

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

ramandeepAuthor
June 23, 2020
Thank you.