CommunicationsException: Communications link failure on docker-compose - java

I'm trying to run a docker-compose with MySQL and I'm getting the classic Communications link failure. I've already read some posts about it, but I still couldn't solve it.
| com.mysql.cj.jdbc.exceptions.CommunicationsException: 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.
Here is a link with code that I'm working on:
https://github.com/JonatasBaldasso/school-registration/tree/fix/docker-compose

Related

MySQL CommunicationsException: Communications link failure [duplicate]

This question already has answers here:
java.net.UnknownHostException: Invalid hostname for server: local
(14 answers)
Kafka Consumer Error - xxxx nodename nor servname provided, or not known
(1 answer)
Closed 1 year ago.
I've seen many topics with that issue but unfortunately I couldn't solve my problem. I've installed MySQL on my server (CentOS 7), I'm able to connect with my DB via shell or MySQL Workbench but when I'm trying to run my Java app, then I'm getting errors like these:
com.mysql.cj.jdbc.exceptions.CommunicationsException: 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.
Caused by: java.net.UnknownHostException: (my server's ip): nodename nor servname provided, or not known
Firewall or proxy can't block connection since I can connect with DB via Workbench or shell..
What's more, I've followed this topic: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure and:
ip address in application.properties is correct
not sure why it could be not recognized
port number is configured to 3306
my DB is running
server accept tcp/ip connections
can't run out of connections since I can connect in same time with Workbench and shell
firewall and proxy is configured to don't block these connections
any ideas what can be wrong with that?
EDIT:
My application.properties configuartion
#Database - deployment
spring.datasource.url=jdbc:mysql://xxx.xx.xxx.xxx/mydbname?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=Europe/Warsaw
spring.datasource.username=mylogin
spring.datasource.password=mypassword
#Hibernate ddl auto (create, create-drop, validate, update)
spring.jpa.hibernate.ddl-auto=create
spring.jpa.database=mysql
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5Dialect
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver

While connecting AWS rds mysql instance getting com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure

While connecting to an AWS rds mysql instance I am getting the below error.
This happens only when I deploy 2 different wars on the same tomcat instance. Both apps connect to their corresponding DB instance (Separate DBs).
If I deploy them separately I don't have an issue.
Here is the error:
com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure
27-Jul-2018 18:31:06.214 SEVERE [pool-27-thread-3] org.apache.tomcat.jdbc.pool.ConnectionPool.init Unable to create initial connections of pool.
com.mysql.cj.jdbc.exceptions.CommunicationsException: 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.
at com.mysql.cj.jdbc.exceptions.SQLError.createCommunicationsException(SQLError.java:741)
at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:57)
at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:1663)
at com.mysql.cj.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:662)
at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:352)
at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:221)
at org.apache.tomcat.jdbc.pool.PooledConnection.connectUsingDriver(PooledConnection.java:307)
at org.apache.tomcat.jdbc.pool.PooledConnection.connect(PooledConnection.java:200)
at org.apache.tomcat.jdbc.pool.ConnectionPool.createConnection(ConnectionPool.java:728)
at org.apache.tomcat.jdbc.pool.ConnectionPool.borrowConnection(ConnectionPool.java:662)
at org.apache.tomcat.jdbc.pool.ConnectionPool.init(ConnectionPool.java:480)
at org.apache.tomcat.jdbc.pool.ConnectionPool.<init>(ConnectionPool.java:154)
at org.apache.tomcat.jdbc.pool.DataSourceProxy.pCreatePool(DataSourceProxy.java:115)
at org.apache.tomcat.jdbc.pool.DataSourceProxy.createPool(DataSourceProxy.java:102)
at org.apache.tomcat.jdbc.pool.DataSourceProxy.getConnection(DataSourceProxy.java:126)
at org.hibernate.engine.jdbc.connections.internal.DatasourceConnectionProviderImpl.getConnection(DatasourceConnectionProviderImpl.java:139)

MySQL JDBC Connector Error

I'm using the latest MySQL version ... in my java application with named pipe and I started receiving the following error like 20 times in a row:
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: 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.
at ......
at ......
at ......
at ......
Caused by: java.io.FileNotFoundException: All pipe instances are busy
... 4 more
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: 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.
at ......
at ......
at ......
at ......
Caused by: java.io.FileNotFoundException: All pipe instances are busy
... 4 more
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: 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.
at ......
at ......
at ......
at ......
Caused by: java.io.FileNotFoundException: All pipe instances are busy
... 4 more
The MySQL server is active and working properly through the command line and PHP. I'm using Windows 7 Ultimate. What is the cause of this java exception and how can I fix this?
Thank you.

Java Mysql Timeout Error

tried everything
connectTimeout=0&socketTimeout=0&autoReconnect=true
changed wait_timeout to 31536000 and interactive_timeout= 286399969
but still continue to get the error.
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
The last packet successfully received from the server was 70,399,485 milliseconds ago

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

I have a java plugin to an application that I'm using (I didn't write it and don't have the source) that connects to my MySQL database...the only problem is that anytime I try to load the application I get a communication link failure
17:51:57 [INFO] Could not create connection: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: 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.
17:51:57 [INFO] Database initialization failed: java.lang.NullPointerException
I have verified that all of my mysql settings are pointing to the correct port that I'm giving this plugin and I've also checked to make sure the user I created for this has privileges over the database it's going to be modifying. I'm out of ideas and it never times out, I would think it was the plugin but the plugin has many users and they use the plugin with MySQL just fine and I continue to have the problem after reinstalling the plugin.
I'm sure it's an issue with MySQL but as far as I can tell...everything is fine, so any clues about what would cause this would be great. I've been reading around and the stuff I've seen didn't help the issue.
SOLUTION
for UBUNTU and MySQL 5.1: Added mysqld : ALL to /etc/hosts.allow
for UBUNTU and MySQL 5.1: Added mysqld : ALL to /etc/hosts.allow

Categories

Resources