Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn more

View all

Sign in to view all badges

SOLVED

Issue while creating a MySql jdbc connection

ramandeep
Level 2
Level 2

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.

1 Accepted Solution
Arun_Patidar
Correct answer by
Community Advisor
Community Advisor

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-...

 

View solution in original post

6 Replies
ramandeep
Level 2
Level 2
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
Employee
Employee

 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

Arun_Patidar
Correct answer by
Community Advisor
Community Advisor

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-...

 

View solution in original post

Veena_Vikram
Community Advisor
Community Advisor

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