我尝试在Netbeans 7.0中连接Postgres postgresql-9.1-902.jdbc4的数据库,我在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
答案 0 :(得分:2)
您似乎正在尝试使用未运行或无法访问的SOCKS
代理。
Caused by: java.net.SocketException: Can't connect to SOCKS proxy:No route to host: connect
确保代理实际上正在运行,并且它可以到达PostgreSQL服务器。尝试使用psql
通过SOCKS代理连接到PostgreSQL服务器以验证是否有效 - 假设您打算通过代理进行连接。
您是否设置了socksProxyHost
和socksProxyPort
系统属性,可能是通过java命令行?请参阅this Java documentation on proxies。
您是否指定了JDBC连接的代理?