开发者

MySQL Connect via proxy in Java

开发者 https://www.devze.com 2023-03-16 11:02 出处:网络
I am developing a client-server software, where the client connects to the database server as follows.

I am developing a client-server software, where the client connects to the database server as follows.

...
try
{
   Class.forName("com.mysql.jdbc.Driver");
   Connection conexion = DriverManager.getConnection("jdbc:mysql://localhost/agenda", "root", "LA_PASSWORD");
}catch....
...

Both applications are always on the same local network. The problem I have is when the local network uses a proxy, in this case the MySQL connection fails.

How I can make a 开发者_JS百科connection with the Java programming language, a MySQL database when a proxy on the local network?.

Thanks for the help. Greetings!


Try using socksProxyHost and socksProxyPort system properties. Look here at chapter "2.4) SOCKS" and here. (The http.proxyHost will not work with JDBC.) Here is description of use proxy with JDBC (Oracle for example): Connect outside internet Oracle Database from inside intranet through JDBC. You may want to use properties: socksProxySet, socksProxyPort, socksProxyHost, java.net.socks.username, java.net.socks.password, socksNonProxyHosts. Here is description how to set version, username, and password. And ofc you need socks proxy, not HTTP.

If you only have HTTP proxy you can try to tunnel JDBC through HTTP. There are few solutions. For example here is free solution http://sourceforge.net/projects/sqlgateway/ and here commercial http://www.idssoftware.com/jdbcdrv.html

0

精彩评论

暂无评论...
验证码 换一张
取 消