微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

org.postgresql.util.PSQLException:连接被拒绝

我想从其他主机testing一个索引函数的执行,因为这个函数在hadoop程序中没有绝对正确的实现。 但是我在连接到其他主机的数据库时遇到了问题,如下所述。 我不明白什么问题。

我写了下面的Java程序

import java.io.*; import java.util.*; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.sqlException; import java.sql.Statement; import java.util.logging.Level; import java.util.*; public class Sample { public static void main (String[] args) throws IOException { int CountComputers; FileInputStream fstream = new FileInputStream( "/export/hadoop-1.0.1/bin/countcomputers.txt"); BufferedReader br = new BufferedReader(new InputStreamReader(fstream)); String result=br.readLine(); CountComputers=Integer.parseInt(result); input.close(); fstream.close(); Connection con = null; Statement st = null; ResultSet rs = null; String url = "jdbc:postgresql://192.168.1.8:5432/NexentaSearch"; String user = "postgres"; String password = "valter89"; //Class.forName("org.postgresql.Driver"); ArrayList<String> paths = new ArrayList<String>(); try { Class.forName("org.postgresql.Driver"); con = DriverManager.getConnection(url,user,password); st = con.createStatement(); rs = st.executeQuery("select path from tasks order by id"); while (rs.next()) { paths.add(rs.getString(1)); }; PrintWriter zzz = null; try { zzz = new PrintWriter(new FileOutputStream("/export/hadoop-1.0.1/bin/readwaysfromdatabase.txt")); } catch(FileNotFoundException e) { System.out.println("Error"); System.exit(0); } for (int i=0; i<paths.size(); i++) { zzz.println("paths[i]=" + paths.get(i) + "n"); } zzz.close(); } catch (sqlException e) { System.out.println("Connection Failed! Check output console"); e.printstacktrace(); } catch (ClassNotFoundException e) { e.printstacktrace(); } } }

我通过一个命令启动了Sample.jar

./java -jar -Djava.library.path=/opt/jdk1.7.0_06/lib /Samplejavaprogram/Sample.jar

结果我收到了以下信息

处理音量的信息

什么是在Windows中采取截图的最快方式?

如何确定Ndis 6filter驱动程序中的802.11原始数据包是否具有FCS(4字节)?

如何让Windows将自定义USB安全性令牌识别为USB令牌而不是COM串行设备

MSI-X在WDF中断

Connection Failed! Check output console org.postgresql.util.PsqlException: Connection refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections. at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:136) at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:66) at org.postgresql.jdbc2.AbstractJdbc2Connection.<init>(AbstractJdbc2Connection.java:125) at org.postgresql.jdbc3.AbstractJdbc3Connection.<init>(AbstractJdbc3Connection.java:30) at org.postgresql.jdbc3.Jdbc3Connection.<init>(Jdbc3Connection.java:24) at org.postgresql.Driver.makeConnection(Driver.java:393) at org.postgresql.Driver.connect(Driver.java:267) at java.sql.DriverManager.getConnection(DriverManager.java:579) at java.sql.DriverManager.getConnection(DriverManager.java:221) at Sample.main(Sample.java:33) Caused by: java.net.ConnectException: Connection timed out at java.net.PlainSocketImpl.socketConnect(Native Method) at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339) at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200) at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182) at java.net.socksSocketImpl.connect(SocksSocketImpl.java:391) at java.net.socket.connect(Socket.java:579) at java.net.socket.connect(Socket.java:528) at java.net.socket.<init>(Socket.java:425) at java.net.socket.<init>(Socket.java:208) at org.postgresql.core.PGStream.<init>(PGStream.java:62) at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:76) ... 9 more

我从一个地址为192.168.1.10的主机启动了这个文件。 帮助消除错误。 在什么原因的错误? 什么是必要的?

netstat -a UDP: IPv4 Local Address Remote Address State -------------------- -------------------- ---------- *.bootpc Idle *.dhcpv6-client Idle *.* Unbound *.* Unbound *.sunrpc Idle *.* Unbound *.38606 Idle *.sunrpc Idle *.* Unbound *.40712 Idle *.* Unbound *.* Unbound *.* Unbound *.54122 Idle *.41742 Idle *.* Unbound *.lockd Idle *.lockd Idle *.59670 Idle *.42840 Idle *.43065 Idle *.39546 Idle *.34243 Idle *.35383 Idle *.40746 Idle *.40832 Idle 192.168.1.2.bootpc Idle *.mdns Idle *.mdns Idle 192.168.1.2.ntp Idle *.snmpd Idle *.ntp Idle *.ntp Idle localhost.localdomain.ntp Idle myhost2.ntp Idle UDP: IPv6 Local Address Remote Address State If --------------------------------- --------------------------------- ---------- ----- *.dhcpv6-client Idle *.* Unbound localhost.44111 localhost.44111 Connected *.sunrpc Idle *.* Unbound *.38606 Idle *.54122 Idle *.* Unbound *.lockd Idle *.42840 Idle *.39546 Idle *.35383 Idle *.40832 Idle *.ntp Idle localhost.ntp Idle TCP: IPv4 Local Address Remote Address Swind Send-Q Rwind Recv-Q State -------------------- -------------------- ----- ------ ----- ------ ----------- localhost.localdomain.4999 *.* 0 0 128000 0 LISTEN *.2001 *.* 0 0 128000 0 LISTEN *.2002 *.* 0 0 128000 0 LISTEN *.2003 *.* 0 0 128000 0 LISTEN *.16049 *.* 0 0 128000 0 LISTEN *.5432 *.* 0 0 128000 0 LISTEN *.sunrpc *.* 0 0 128000 0 LISTEN *.* *.* 0 0 128000 0 IDLE *.sunrpc *.* 0 0 128000 0 LISTEN *.* *.* 0 0 128000 0 IDLE *.54002 *.* 0 0 128000 0 LISTEN *.49023 *.* 0 0 128000 0 LISTEN *.55493 *.* 0 0 1049200 0 LISTEN *.46659 *.* 0 0 1048952 0 LISTEN *.lockd *.* 0 0 1049200 0 LISTEN *.lockd *.* 0 0 1048952 0 LISTEN *.45361 *.* 0 0 128000 0 LISTEN localhost.localdomain.36084 localhost.localdomain.2001 65440 0 139264 0 ESTABLISHED *.53943 *.* 0 0 128000 0 LISTEN localhost.localdomain.2001 localhost.localdomain.36084 139060 0 130880 0 ESTABLISHED localhost.localdomain.44644 localhost.localdomain.2012 34765 0 139264 0 ESTABLISHED localhost.localdomain.2012 localhost.localdomain.44644 139060 0 139060 0 ESTABLISHED *.36068 *.* 0 0 128000 0 LISTEN *.57055 *.* 0 0 128000 0 LISTEN *.login *.* 0 0 128000 0 LISTEN *.finger *.* 0 0 128000 0 LISTEN *.telnet *.* 0 0 128000 0 LISTEN *.shell *.* 0 0 128000 0 LISTEN *.40524 *.* 0 0 128000 0 LISTEN *.60838 *.* 0 0 128000 0 LISTEN *.47648 *.* 0 0 128000 0 LISTEN *.56894 *.* 0 0 128000 0 LISTEN *.48461 *.* 0 0 128000 0 LISTEN *.53672 *.* 0 0 128000 0 LISTEN *.42108 *.* 0 0 128000 0 LISTEN *.63720 *.* 0 0 128000 0 LISTEN *.ssh *.* 0 0 128000 0 LISTEN localhost.localdomain.smtp *.* 0 0 128000 0 LISTEN localhost.localdomain.submission *.* 0 0 128000 0 LISTEN *.80 *.* 0 0 128000 0 LISTEN *.* *.* 0 0 128000 0 IDLE *.2000 *.* 0 0 128000 0 LISTEN *.* *.* 0 0 128000 0 IDLE *.443 *.* 0 0 128000 0 LISTEN *.* *.* 0 0 128000 0 IDLE localhost.localdomain.38137 localhost.localdomain.2003 65440 0 139264 0 ESTABLISHED localhost.localdomain.2003 localhost.localdomain.38137 139060 0 130880 0 ESTABLISHED localhost.localdomain.63918 localhost.localdomain.2001 65440 0 139264 0 ESTABLISHED localhost.localdomain.2001 localhost.localdomain.63918 139060 0 130880 0 ESTABLISHED myhost2.ssh 192.168.1.4.7431 65548 0 128480 0 ESTABLISHED localhost.localdomain.34057 localhost.localdomain.2001 65440 0 139264 0 ESTABLISHED localhost.localdomain.2001 localhost.localdomain.34057 139060 0 130880 0 ESTABLISHED localhost.localdomain.37015 localhost.localdomain.2001 65440 0 139264 0 ESTABLISHED localhost.localdomain.2001 localhost.localdomain.37015 139060 0 130880 0 ESTABLISHED *.2011 *.* 0 0 131072 0 LISTEN localhost.localdomain.36598 localhost.localdomain.2002 65440 0 139264 0 ESTABLISHED localhost.localdomain.2002 localhost.localdomain.36598 139060 0 130880 0 ESTABLISHED localhost.localdomain.4000 *.* 0 0 131072 0 LISTEN localhost.localdomain.53161 localhost.localdomain.2011 34765 0 139264 0 ESTABLISHED localhost.localdomain.2011 localhost.localdomain.53161 139060 0 139060 0 ESTABLISHED localhost.localdomain.43878 localhost.localdomain.2001 65440 0 139264 0 ESTABLISHED localhost.localdomain.2001 localhost.localdomain.43878 139060 0 130880 0 ESTABLISHED localhost.localdomain.50976 localhost.localdomain.2001 65440 0 139264 0 ESTABLISHED localhost.localdomain.2001 localhost.localdomain.50976 139060 0 130880 0 ESTABLISHED localhost.localdomain.62633 localhost.localdomain.2012 34765 0 139264 0 ESTABLISHED localhost.localdomain.2012 localhost.localdomain.62633 139060 0 139060 0 ESTABLISHED *.2012 *.* 0 0 131072 0 LISTEN localhost.localdomain.34418 localhost.localdomain.2012 34765 0 139264 0 ESTABLISHED localhost.localdomain.2012 localhost.localdomain.34418 139060 0 139060 0 ESTABLISHED localhost.localdomain.34356 localhost.localdomain.2011 34765 0 139264 0 ESTABLISHED localhost.localdomain.2011 localhost.localdomain.34356 139060 0 139060 0 ESTABLISHED localhost.localdomain.62884 localhost.localdomain.2001 65440 0 139264 0 ESTABLISHED localhost.localdomain.2001 localhost.localdomain.62884 139060 0 130880 0 ESTABLISHED localhost.localdomain.52603 localhost.localdomain.2011 34765 0 139264 0 ESTABLISHED localhost.localdomain.2011 localhost.localdomain.52603 139060 0 139060 0 ESTABLISHED localhost.localdomain.35345 localhost.localdomain.2001 65440 0 139264 0 ESTABLISHED localhost.localdomain.2001 localhost.localdomain.35345 139060 0 130880 0 ESTABLISHED localhost.localdomain.49022 localhost.localdomain.2001 130880 0 139264 0 TIME_WAIT localhost.localdomain.42797 localhost.localdomain.2001 130880 0 139264 0 TIME_WAIT localhost.localdomain.46312 localhost.localdomain.2001 130880 0 139264 0 TIME_WAIT TCP: IPv6 Local Address Remote Address Swind Send-Q Rwind Recv-Q State If --------------------------------- --------------------------------- ----- ------ ----- ------ ----------- ----- *.5432 *.* 0 0 128000 0 LISTEN *.sunrpc *.* 0 0 128000 0 LISTEN *.* *.* 0 0 128000 0 IDLE *.54002 *.* 0 0 128000 0 LISTEN *.55493 *.* 0 0 1049200 0 LISTEN *.lockd *.* 0 0 1049200 0 LISTEN *.53943 *.* 0 0 128000 0 LISTEN *.57055 *.* 0 0 128000 0 LISTEN *.login *.* 0 0 128000 0 LISTEN *.finger *.* 0 0 128000 0 LISTEN *.telnet *.* 0 0 128000 0 LISTEN *.shell *.* 0 0 128000 0 LISTEN *.60838 *.* 0 0 128000 0 LISTEN *.56894 *.* 0 0 128000 0 LISTEN *.53672 *.* 0 0 128000 0 LISTEN *.63720 *.* 0 0 128000 0 LISTEN *.ssh *.* 0 0 128000 0 LISTEN localhost.smtp *.* 0 0 128000 0 LISTEN *.80 *.* 0 0 128000 0 LISTEN *.2000 *.* 0 0 128000 0 LISTEN *.443 *.* 0 0 128000 0 LISTEN Active UNIX domain sockets Address Type Vnode Conn Local Addr Remote Addr ffffff0119f107b8 stream-ord 00000000 00000000 ffffff0119f10b68 stream-ord 00000000 00000000 ffffff0119214050 stream-ord 00000000 00000000 ffffff0119214400 stream-ord 00000000 00000000 ffffff0119214b60 stream-ord 00000000 00000000 ffffff0114119048 stream-ord 00000000 00000000 ffffff01141193f8 stream-ord ffffff011950e580 00000000 /tmp/dbus-3YiNfXlgwn ffffff01141197a8 stream-ord ffffff0119217e40 00000000 /tmp/dbus-7BNzAEnmYY ffffff0114119b58 stream-ord ffffff0114118e40 00000000 /var/run/mDNSResponder ffffff01138b2040 stream-ord 00000000 00000000 /var/run/dbus/system_bus_socket ffffff01138b23f0 stream-ord 00000000 ffffff0111d0e780 /var/run/dbus/system_bus_socket ffffff01138b27a0 stream-ord 00000000 00000000 /var/run/dbus/system_bus_socket ffffff01138b2b50 stream-ord 00000000 ffffff0111d0e780 /var/run/dbus/system_bus_socket ffffff0113059038 stream-ord ffffff0113835140 00000000 /var/run/.inetd.uds ffffff01130593e8 stream-ord 00000000 ffffff0112c5f880 /var/run/hald/dbus-9g2E5zdff9 ffffff0113059798 stream-ord 00000000 00000000 /var/run/hald/dbus-9g2E5zdff9 ffffff0113059b48 dgram ffffff01130b2e00 00000000 /var/run/in.ndpd_mib ffffff011306d030 stream-ord ffffff0112bb5280 00000000 /var/run/in.ndpd_ipadm ffffff011306d3e0 stream-ord 00000000 00000000 /var/run/hald/dbus-9g2E5zdff9 ffffff011306d790 stream-ord 00000000 00000000 /var/run/hald/dbus-9g2E5zdff9 ffffff011306db40 stream-ord 00000000 ffffff0112c5f880 /var/run/hald/dbus-9g2E5zdff9 ffffff0112fcb028 stream-ord 00000000 ffffff0112c5f880 /var/run/hald/dbus-9g2E5zdff9 ffffff0112fcb3d8 stream-ord 00000000 00000000 /var/run/hald/dbus-9g2E5zdff9 ffffff0112fcb788 stream-ord 00000000 ffffff0112c5f880 /var/run/hald/dbus-9g2E5zdff9 ffffff0112fcbb38 stream-ord ffffff0112fd4080 00000000 /tmp/.s.PGsql.5432 ffffff01122c4020 stream-ord 00000000 00000000 /var/run/hald/dbus-F83hT9CGSX ffffff01122c43d0 stream-ord 00000000 ffffff0112c5f280 /var/run/hald/dbus-F83hT9CGSX ffffff01122c4780 stream-ord ffffff0112c5f280 00000000 /var/run/hald/dbus-F83hT9CGSX ffffff01122c4b30 stream-ord 00000000 00000000 ffffff0112294018 stream-ord 00000000 00000000 ffffff01122943c8 stream-ord ffffff0112c5f880 00000000 /var/run/hald/dbus-9g2E5zdff9 ffffff0112294778 stream-ord 00000000 00000000 ffffff0112294b28 stream-ord 00000000 00000000 ffffff0112278010 stream-ord ffffff01122c7880 00000000 /tmp/dbus-PuCCfO9I4C ffffff01122783c0 stream-ord 00000000 00000000 ffffff0112278770 stream-ord 00000000 00000000 ffffff0112278b20 stream-ord ffffff01122a0b40 00000000 /tmp/dbus-tfcmjjMClq ffffff0111d08008 stream-ord 00000000 00000000 ffffff0111d083b8 stream-ord 00000000 00000000 ffffff0111d08768 stream-ord ffffff01121a2b40 00000000 /tmp/dbus-cEAGQX2WDo ffffff0111d08b18 stream-ord ffffff0111d0e780 00000000 /var/run/dbus/system_bus_socket

Postgresql启动?

在Windows XP或更高版本中,以编程方式从文件夹执行相同的安装驱动程序

Linux的USB连接/断开事件

有没有人熟悉未公开的ObReferenceObjectByName窗口内核函数

如何以编程方式从联机待机唤醒Windows 8.1

我们如何检查安装的扫描仪驱动程序是Windows 10 Professional(64位)上的32位或64位?

错误“检查主机名和端口是否正确,并且postmaster正在接受TCP / IP连接。 建议:

Postgres没有启动,检查此运行netstat -a并检查Postgres是否正在等待5432端口上的连接

错误用户名/密码 – 尝试使用控制台或PG管理员使用这些凭据连接到Postgres

这可能会发生,特别是如果Postgres在Linux上,由于安全原因,不允许TCP / IP连接。 你需要启用它。 搜索“启用远程Postgres连接”或“启用Postgres的TCP / IP连接”,有信息的掌握。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐