爱国者
爱国者

Reputation: 4328

Can Java program establish JDBC Connection via Proxy Server

I want to communicate to Oracle DB Server which sits outside my network via the proxy server. I can access the web application hosted on the same machine via Browser with proxy settings. Can a simple Java program establish JDBC Connection thru the proxy server?

*To provide an example will be better *

Regards.

Upvotes: 8

Views: 29402

Answers (2)

Tagar
Tagar

Reputation: 14891

Oracle JDBC (and any other JDBC connections to that extent) are not HTTP-based protocols, so the proxying has to be done at TCP layer.

For this reason, you can't use Squid Proxy for example (which only does proxying at HTTP layer), but there are many other proxying services that can work at TCP layer:

  • nginx proxy
  • haproxy

On the former there is a nice step by step guide how to setup JDBC proxying using NGINX https://kwjrnl.wordpress.com/2015/07/27/tcp-proxy-with-nginx-for-jdbc-connection/

Upvotes: 1

kovica
kovica

Reputation: 2583

If the proxy is only a HTTP proxy, then no. But if the proxy transfers TCP/IP trafic, then you can.

How to do that, look at How do I set the proxy to be used by the JVM or http://docs.oracle.com/javase/6/docs/technotes/guides/net/proxies.html

Upvotes: 6

Related Questions