2015-06-04 160 views
5

我一直试图连接到我的postgres数据库整天。我可以通过pgAdmin来完成,但是我无法通过mySQLWorkbench连接来迁移它,也无法通过Intellij IDEA连接。我们将开始瓦特/的IntelliJ虽然...通过Intellij IDEA连接到Postgres Heroku DB

所以,当我试图通过的IntelliJ连接时,我得到这个...

Connection to Sinthetics failed 
java.sql.SQLException: SSL error: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target 

我认为这意味着,我需要一个证书,因为我使用SSL(因为它是一个postgres/heroku)。所以,我跑我得心应手InstallCert是这样的...

java InstallCert ec2-54-243-235-169.compute-1.amazonaws.com:5432 

而且把它恢复:为什么我不能得到这个证书

Loading KeyStore /usr/lib/jvm/java-7-openjdk-amd64/jre/lib/security/cacerts... 
Opening connection to ec2-54-243-235-169.compute-1.amazonaws.com:5432... 
Starting SSL handshake... 

javax.net.ssl.SSLHandshakeException: Remote host closed connection during handshake 
    at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:953) 
    at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1332) 
    at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1359) 
    at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1343) 
    at InstallCert.main(InstallCert.java:87) 
Caused by: java.io.EOFException: SSL peer shut down incorrectly 
    at sun.security.ssl.InputRecord.read(InputRecord.java:482) 
    at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:934) 
    ... 4 more 
Could not obtain server certificate chain 

这样,不过这没有问题,连接pgAdmin的!?有没有人有线索?

回答

21

要添加到您的IntelliJ IDEA的PostreSQL在Heroku上新的连接,你需要:

  1. 数据库工具窗口/新建/数据源/ PostreSQL

  2. 认沽主机,端口,数据库,用户,您在https://postgres.heroku.com/databases

  3. 去找到高级选项卡,把密码:

    • SSL:真
    • sslfactory:org.postgresql.ssl.NonValidatingFactory
  4. 利润。

+0

这并没有为我工作,我得到一个错误: 抛出java.lang.ClassNotFoundException:org.postgresql.ssl.NonValidatingFactory [2017年1月20日19点五十二分20秒] \t是java。 net.URLClassLoader.findClass(URLClassLoader.java:381) [2017-01-20 19:52:20] \t at java.lang.ClassLoader.loadClass(ClassLoader.java:424) [2017-01-20 19: 52:20] \t at ... – Pille

+0

对我而言,这工作。谢谢! – studersi