1
votes

We have a pristine Debian 7 on a virtual server. Tomcat7 with OpenJDK 1.7.0_65 connecting to a local MySQL 5.5 installation. A tomcat application with ColdFusion core (Razuna, a MAM) throws this exception when installing:

com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create connection to database server. Attempted reconnect 3 times. Giving up.

As far as looking this exception up, there are a multitude of reasons for the exception itself, so the message after the exception type is important.

We've dumped the ColdFusion database connection object, and it looks like this:

struct
connectionretries 0
connectiontimeout 120
connectstring zeroDateTimeBehavior=convertToNull
databasename razuna
description [empty string]
displayname mysql
drivername com.mysql.jdbc.Driver
hoststring jdbc:mysql://localhost:3306/razuna?cacheResultSetMetadata=false&autoReconnect=true&useEncoding=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull
initstring [empty string]
logintimeout 120
maxconnections 3
name mysql
password [thecorrectpassword]
perrequestconnections false
port 3306
server localhost
sqldelete true
sqlinsert true
sqlselect true
sqlstoredprocedures true
sqlupdate true
username razuna

It looks good. So we've tried to diagnose the problem on the MySQL side. After switching on general logging, we can see that there's no entry in the general log. The last things we thought of was to give the Tomcat7 user an interactive shell, then try to log into MySQL manually using the same parameters (host, port, user, password), and this works like a charm. Also, comparing the softwares of another server (with the same provider) where the same application works under the same circumstances, everything seems to be the same: Debian version, Java version and flavour, Tomcat-version.

We have no real idea how to proceed from here. Any help is appreciated.

Edit 1: We've already tried it with the root MySQL user, just to rule out the possibility of it being some strange permissions problem with the dedicated user for the application. The error message was the same.

1
What connection you are using IPV4 or IPV6? - Deepu--Java
It should be an IPv4 connection, as far as we can tell. The server has no v6 address. But isn't a local connection to a MySQL instance using a socket anyway? - 0xCAFEBABE

1 Answers

0
votes

Try these resolutions. Any one might help you:

  1. If you have IPv6 enabled on your system, try 127.0.0.1 instead of localhost.

  2. GRANT ALL PRIVILEGES ON *.* TO 'localhost'@'%' IDENTIFIED BY PASSWORD '52819c504481470a' WITH GRANT OPTION MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0;