Unanswered: Couldn't connect to database. java.sql.SQLException: Unable to connect to any hosts
I'm trying to connect to a MYSQL server via a tomcat running with -security. The machine in question is running RedHat 7.1
My development system, running under windows, with the same setup tomcat works fine. (I've granted the appropriate permissions in the catalina.policy file)
I'm using the latest jConnector MySQL driver.
The full error message I get is:- java.sql.SQLException: Unable to connect to any hosts due to exception: java.security.AccessControlException: access denied (java.net.SocketPermission localhost resolve)
Can anyone help ?
I *can* connect remotely to the database using the mySQL Control center, but Java can't when its run on the local machine.
Re: Couldn't connect to database. java.sql.SQLException: Unable to connect to any hos
I'm having a similar problem. The jdbc driver loads ok, but when I try to connect to mysql I get this exception:
java.sql.SQLException: Unable to connect to any hosts due to exception: java.net.ConnectException: Connection refused
I'm running tomcat on linux. The same application works fine when I run it under windows. I'm also succesfully using mysql with apache+php on the same linux machine, so I'm led to suspect that the problem is somewhere in tomcat confs (I didn't install it myself). Any pointers what I should look for? Thanks!
EDIT: Seems you need to disable skip-networking in my.cnf even if connecting to localhost.