Skip to main content

Communications link failure The last packet sent successfully to the server was 0 milliseconds ago

2 replies [Last post]
reos
Offline
Joined: 2005-06-28
Points: 0

Hi, I'm trying to connect to a mysql server on a linux server. The appserver and the dbserver are on the same server. I have configured the mysql to accept connections on my ip address (differente from 127.0.0.1). I can connect to the database from a remote machine. But if I try to create a connection pool from my glassfish server I get this error.

Communications link failure The last packet sent successfully to the server was 0 milliseconds ago

I have seen some answers on internet including this:
http://edwin.baculsoft.com/2011/11/error-communications-link-failure-whe...

But the problem is that if I change the IP to 127.0.0.1 I wont connect to mysql from external ip address.

I want to know how do you approach this issue.

Thank you for yor answers.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Roel_D

What username and password do you use in glassfish for connecting to mysql?

You need to give this user rights to connect!

In mysql: grant all on *.* to 'glassfish'@'127.0.0.1' identified by 'glassfish' ;

This will create a user named glassfish with a password glassfish that has all rights.

Set in my.cnf "skip-name-resolve'. In case mysql can't resolve the hostname of 127.0.0.1

Kind regards,

The out-side

Op 22 okt. 2012 om 02:17 heeft forums@java.net het volgende geschreven:

> Hi, I'm trying to connect to a mysql server on a linux server. The appserver
> and the dbserver are on the same server. I have configured the mysql to
> accept connections on my ip address (differente from 127.0.0.1). I can
> connect to the database from a remote machine. But if I try to create a
> connection pool from my glassfish server I get this error. Communications
> link failure The last packet sent successfully to the server was 0
> milliseconds ago I have seen some answers on internet including this:
> http://edwin.baculsoft.com/2011/11/error-communications-link-failure-whe...
> But the problem is that if I change the IP to 127.0.0.1 I wont connect to
> mysql from external ip address. I want to know how do you approach this
> issue. Thank you for yor answers.
>
> --
>
> [Message sent by forum member 'reos']
>
> View Post: http://forums.java.net/node/891638
>
>

reos
Offline
Joined: 2005-06-28
Points: 0

Thank you for replying.

Finally I found the problem. In the list of parameters of the connection pool there were two properties named URL. I had filled only one correctly and the other was different. I put the same value on both and it worked.