Results 1 to 2 of 2
  1. #1
    cucucur is offline Member
    Join Date
    Apr 2011
    Posts
    20
    Rep Power
    0

    Default connect to remote mysql server

    hi! I'm trying to connect to a remote mysql server what I do is:

    Java Code:
     public static Connection connectDB(){
    
        	Connection conn = null;
        	try {
                Class.forName("com.mysql.jdbc.Driver").newInstance();
        	    conn = DriverManager.getConnection("jdbc:mysql://ip:3306/spb", "user", "pass");
        	        	    
            } catch (Exception e){
            	System.out.println(e.toString());
            } 
            return conn;
        }
    I got this exception,

    Java Code:
    com.mysql.jdbc.CommunicationsException: Communications link failure due to underlying exception: 
    
    ** BEGIN NESTED EXCEPTION ** 
    
    java.net.ConnectException
    MESSAGE: Connection timed out: connect
    
    STACKTRACE:
    
    java.net.ConnectException: Connection timed out: connect
    	at java.net.PlainSocketImpl.socketConnect(Native Method)
    	at java.net.PlainSocketImpl.doConnect(Unknown Source)
    	at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
    	at java.net.PlainSocketImpl.connect(Unknown Source)
    	at java.net.SocksSocketImpl.connect(Unknown Source)
    	at java.net.Socket.connect(Unknown Source)
    	at java.net.Socket.connect(Unknown Source)
    	at java.net.Socket.<init>(Unknown Source)
    	at java.net.Socket.<init>(Unknown Source)
    	at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:256)
    	at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:271)
    	at com.mysql.jdbc.Connection.createNewIO(Connection.java:2771)
    	at com.mysql.jdbc.Connection.<init>(Connection.java:1555)
    	at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:285)
    	at java.sql.DriverManager.getConnection(Unknown Source)
    	at java.sql.DriverManager.getConnection(Unknown Source)
    	at mysqlRemoto.connectDB(mysqlRemoto.java:20)
    	at mysqlRemoto.main(mysqlRemoto.java:44)
    
    
    ** END NESTED EXCEPTION **
    
    
    
    Last packet sent to the server was 1 ms ago.
    Do I have to do something in my server? Thanks!!!

  2. #2
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    9

    Default

    That sounds like either a firewall dropping packets (either on the way to the db server or on the way back) or bad routing that essentially sends the packet in circles.

Similar Threads

  1. How to create remote client to connect with MS Access?
    By Constance in forum New To Java
    Replies: 9
    Last Post: 10-19-2012, 04:16 AM
  2. Replies: 0
    Last Post: 03-14-2011, 07:56 AM
  3. Java to connect remote server
    By idealguy in forum New To Java
    Replies: 1
    Last Post: 12-14-2010, 11:40 AM
  4. Replies: 4
    Last Post: 04-28-2010, 06:13 PM
  5. failed to connect to remote vm
    By plummer in forum Eclipse
    Replies: 1
    Last Post: 05-08-2009, 08:11 AM

Posting Permissions

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