1

I try to connect with a database of Postgres postgresql-9.1-902.jdbc4 in Netbeans 7.0 and I get this error in Java :

jul 19, 2012 9:35:02 AM databasedesktop.DatabaseDesktopApp startup
Grave: null
org.postgresql.util.PSQLException: El intento de conexión falló.
    at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:150)
    at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:64)
    at org.postgresql.jdbc2.AbstractJdbc2Connection.<init>(AbstractJdbc2Connection.java:123)
    at org.postgresql.jdbc3.AbstractJdbc3Connection.<init>(AbstractJdbc3Connection.java:28)
    at org.postgresql.jdbc3g.AbstractJdbc3gConnection.<init>(AbstractJdbc3gConnection.java:20)
    at org.postgresql.jdbc4.AbstractJdbc4Connection.<init>(AbstractJdbc4Connection.java:30)
    at org.postgresql.jdbc4.Jdbc4Connection.<init>(Jdbc4Connection.java:22)
    at org.postgresql.Driver.makeConnection(Driver.java:391)
    at org.postgresql.Driver.connect(Driver.java:265)
    at java.sql.DriverManager.getConnection(DriverManager.java:579)
    at java.sql.DriverManager.getConnection(DriverManager.java:221)
    at databasedesktop.DatabaseDesktop.initDatabasePostgre(DatabaseDesktop.java:45)
    at databasedesktop.DatabaseDesktop.<init>(DatabaseDesktop.java:56)
    at databasedesktop.DatabaseDesktopApp.startup(DatabaseDesktopApp.java:22)
    at org.jdesktop.application.Application$1.run(Application.java:171)
    at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:251)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:705)
    at java.awt.EventQueue.access$000(EventQueue.java:101)
    at java.awt.EventQueue$3.run(EventQueue.java:666)
    at java.awt.EventQueue$3.run(EventQueue.java:664)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:675)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:211)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:128)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:117)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:113)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:105)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:90)
Caused by: java.net.SocketException: Can't connect to SOCKS proxy:No route to host: connect
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:427)
    at java.net.Socket.connect(Socket.java:578)
    at java.net.Socket.connect(Socket.java:527)
    at java.net.Socket.<init>(Socket.java:424)
    at java.net.Socket.<init>(Socket.java:207)
    at org.postgresql.core.PGStream.<init>(PGStream.java:60)
    at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:74)
    ... 28 more
5
  • 2
    is your postgres instance running? Commented Jul 19, 2012 at 15:25
  • 2
    Can you connect to your database with pgadmin? Commented Jul 19, 2012 at 16:48
  • Yes my instance of postgres in running Commented Jul 20, 2012 at 16:45
  • yes i connect to database good Commented Jul 20, 2012 at 16:45
  • @viktor: Have you abandoned this question? Found a solution? Commented Jul 28, 2012 at 15:27

1 Answer 1

2

You appear to be trying to use a SOCKS proxy that is not running or reachable.

Caused by: java.net.SocketException: Can't connect to SOCKS proxy:No route to host: connect

Make sure that the proxy is actually running, and that it can reach the PostgreSQL server. Try using psql to connect to the PostgreSQL server via your SOCKS proxy to verify that works - assuming you intended to connect via the proxy.

Have you set the socksProxyHost and socksProxyPort system properties, perhaps via the java command line? See this Java documentation on proxies.

Are you specifying a proxy to your JDBC connection?

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

3 Comments

I try to connect to a database first locally and i get the same error and to other machine i get the same
@viktor I don't really understand what you just said there, sorry. It still sounds like a configuration problem with your Java runtime or your connection string. Please update your question with (a) a dump of your system properties from the System.getProperties() call (iterate through them and print them to System.out) and (b) your JDBC connection string or properties map.
@viktor Are you intentionally using a SOCKS proxy, by the way? Is the proxy set up on purpose?

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.