2015-06-04 197 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