1

Could someone help me or suggest a solution? I want to connect from a computer that has firewall to other where the postgres server run. The problem is that computer (client) has a firewall and I don't have access to configure it, or open ports, ping does not respond. The computer (server) where PostgreSQL has open ports but I cannot connect to it from another because of a firewall. I can only access the computer through proxy.

How I could with Java programming access remotely through proxy to postgres forgetting firewall?

Java has a connection with proxies. But I don't know how to put it together with postgres connection.

        System.getProperties().put( "proxySet", "true" );
        System.getProperties().put( "proxyHost", "67.210.82.198" );
        System.getProperties().put( "proxyPort", "80" );

        URL validateURL = new URL("http://domain.com");
        URLConnection urlConnection = validateURL.openConnection();

        //how put together ???

        Class.forName("org.postgresql.Driver");
        Connection connection =  DriverManager.getConnection("jdbc:postgresql://ipPublica:5432/DataBase","user", "pass"); 
1
  • "proxySet" does nothing. Proof: set it to "false". There is not and has never been such a property in the JDK, various books and online references notwithstanding. It came from the long-defunct HotJavaBean, an encapsulated browser, died a death in about 1998. Commented Apr 8, 2011 at 0:19

4 Answers 4

6

That can't be done. PostgreSQL connections are not HTTP connections. Yo cannot use an HTTP proxy for PostgreSQL. Maybe a socks proxy will do the work.

Sign up to request clarification or add additional context in comments.

Comments

1

Try

System.setProperty("http.proxyHost", "67.210.82.198");
System.setPropery("http.proxyPort", "80");

String url = "jdbc:postgresql://host:port/database";
Properties props = new Properties();
props.setProperty("user","myUsername");
props.setProperty("password","myPassword");
props.setProperty("ssl","true");

Class.forName("org.postgresql.Driver");
Connection conn = DriverManager.getConnection(url, props);

For more, see java networking & proxies.

1 Comment

Thank you very much friend on monday will test with firewall, now i test locally (postgres server) and it work ;) Thanks
0

This question is quite old. It also has been asked on the PostgreSQL mailing list:

http://archives.postgresql.org/pgsql-jdbc/2010-08/msg00021.php

The answers over there boils down to:

  • Use SOCKs

  • If (big IF!) you want to hack the JDBC driver source, you might (big "might"!) be able to make it work over a HTTP-Proxy using SSL.

  • Sidekick: Someone proposed an ssh tunnel.

Comments

0

You'll need a SOCKS proxy, rather than a HTTP proxy.

Then your code will look something like this:

System.setProperty("socksProxyHost", host);
System.setProperty("socksProxyPort", "1080");

Details: http://docs.oracle.com/javase/7/docs/technotes/guides/net/proxies.html

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.