我正在运行Amazon RDS Postgres实例.我可以看到本地机器(白名单办公室IP)的数据和我们的网络应用程序可以连接(在EC2实例上运行).
在那个EC2实例上,这些事情发生了:
[ec2-user@ip ~]$nc -zv mydb.us-east-1.rds.amazonaws.com 5432
Connection to mydb.us-east-1.rds.amazonaws.com 5432 port [tcp/postgres] succeeded!
[ec2-user@ip ~]$psql postgres -h mydb.us-east-1.rds.amazonaws.com -U userguy
Password for user userguy:
psql (9.5.4, server 9.6.1)
WARNING: psql major version 9.5, server major version 9.6.
Some psql features might not work.
SSL connection (protocol: TLSv1.2, cipher: ECDHE-RSA-AES256-GCM-SHA384, bits: 256, compression: off)
Type "help" for help.
postgres=> \q
[ec2-user@ip myjars]$java -jar MyJar.jar param1
Connecting to jdbc:postgresql://mydb.us-east-1.rds.amazonaws.com:5432/postgres
org.postgresql.util.PSQLException: Connection refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.
我知道这个EC2实例可以连接到DB. nc命令有效,psql命令有效.我们还有一个连接的Glassfish应用服务器.
此JAR文件中的参数相同,但不起作用!有什么想法吗?有任何诊断想法吗? (当我输入此内容时,我觉得它将是JAR文件中的某个文件版本或错误值,因为其他所有内容都正常工作)