Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2003
    Posts
    1

    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.

  2. #2
    Join Date
    Mar 2004
    Posts
    1

    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!

    - jp

    EDIT: Seems you need to disable skip-networking in my.cnf even if connecting to localhost.
    Last edited by xtc; 04-01-04 at 07:19.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •