Cant connect to MySQL server from Java application
- by RN
This is on VPS\Centos server. The MySQL server is pre configured.
I am running the Java application on Tomcat
My Java web application is not able to connect to the MySQL server.
I get an error -
"Caused by: java.net.ConnectException: Connection refused"
I suspect this to be a configuration problem rather than a coding problem- hence I have posted this on ServerFault
And yes, The same web-app is able to connect to MySQL on a different linux box
This is the URL that I provided to my Java application (note- it assumes default port)
url = "jdbc:mysql://localhost/pickupgames"
My first suspicion was that I am running on a non-default port
So I tried to find the port where mySQL server is running
I tried every trick mentioned in http://serverfault.com/questions/116100/how-to-check-what-port-mysql-is-running-on
But no luck !
SHOW GLOBAL VARIABLES LIKE 'PORT';
This shows port 0
netstat -tlnp
doesn't show mysql at all
/etc/my.cnf
It has no port entry
telnet localhost 3306
Doesn't connect
And in case you are wondering if mysql server is running at all or not
It is
And I know for sure, because I have been able to login using the mysql command
Also
# ps -ef|grep 'mysql'
root 31839 27662 0 00:49 pts/3 00:00:00 grep mysql
root 32452 1 0 Apr02 ? 00:00:00 /bin/sh /usr/bin/mysqld_safe --skip-grant-tables --skip-networking
mysql 32504 32452 0 Apr02 ? 00:00:06 /usr/libexec/mysqld --basedir=/usr --datadir=/var/lib/mysql --user=mysql --pid-file=/var/run/mysqld/mysqld.pid --skip-external-locking --socket=/var/lib/mysql/mysql.sock --skip-grant-tables --skip-networking
Please note the --skip-networking parameter
Does this have something to do with the issue ?
Any explanation why I cant connect to mysql server on port 3306 by telnet?
Or why it docent show up under netstat?
Any suggestion on whet I should try next ?