Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Connecting to mySQL database, timeout error

807597Apr 13 2005 — edited Apr 13 2005
I am having problems connecting to my database, here is the connection class
public class DBConnect
{   
    public static Connection getDBConnect() throws Exception
    {         
        String x = "worked";
        //String url = "jdbc:mysql://mysql8.secureserver.net";
        String url = "jdbc:mysql://mysql13.secureserver.net/DBName?user=User&password=Password";
        System.out.println("Before driver load");
        try 
        {
            Class.forName("com.mysql.jdbc.Driver");
            System.out.println("Driver Loaded");
        }
        catch(java.lang.ClassNotFoundException e) 
        {
            System.err.print("ClassNotFoundException: ");
            System.err.println(e.getMessage());
        }
        System.out.println("After driver loaded and Before connect");
            Connection con = DriverManager.getConnection(url);
            System.out.println("Tried connect");
            return con;        
    }  
}
here is the error:
INFO: Server startup in 17685 ms
com.mysql.jdbc.CommunicationsException: Communications link failure due to underlying exception: 

** BEGIN NESTED EXCEPTION ** 

java.net.SocketException
MESSAGE: java.net.ConnectException: Connection timed out: connect

STACKTRACE:

java.net.SocketException: java.net.ConnectException: Connection timed out: connect
	at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:151)
	at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:280)
	at com.mysql.jdbc.Connection.createNewIO(Connection.java:1765).....
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 11 2005
Added on Apr 13 2005
5 comments
372 views