Skip to Main Content

Java APIs

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!

How to connect to mysql database using a proxy

843790Feb 6 2007 — edited Feb 6 2007
Folks,

I wrote a program to connect to both webpage and mysql databases. Because my internet has a firewall (proxy) I set up the internet connection like this:
      System.getProperties().put( "proxySet", "true" );
      System.getProperties().put( "proxyHost", proxyHost);
      System.getProperties().put( "proxyPort", proxyPort);
      Authenticator.setDefault(new MyAuthenticator());
The http connection works fine. However the mysql database connection gives me an error:
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:156) 
        at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:276) 
        at com.mysql.jdbc.Connection.createNewIO(Connection.java:2666) 
        at com.mysql.jdbc.Connection.<init>(Connection.java:1531) 
        at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:266) 
        at java.sql.DriverManager.getConnection(Unknown Source) 
        at java.sql.DriverManager.getConnection(Unknown Source) 
        at myapplication$LongTask$ActualTask.<init>(app.java:182) 
        at myapplication$LongTask$1.construct(app.java:121) 
        at myapplication.SwingWorker$2.run(SwingWorker.java:107) 
        at java.lang.Thread.run(Unknown Source) 
 
 
** END NESTED EXCEPTION ** 
What can I do? Do i need to setup a SOCKS Proxies or something?

Thanks a lot!!
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 6 2007
Added on Feb 6 2007
1 comment
582 views