我正在设置一个新的数据库服务器,并希望通过IDEA数据库工具进行操作。但是,我无法连接到我的远程服务器,而对于本地数据库则可以。我敢肯定我正确填写了每个领域。
我已经下载了驱动程序文件,甚至将其添加到项目库中。
pg_hba.conf
配置为使用md5 auth从任何地方接受连接。我还编辑了postgresql.conf以监听"*"
。
奇怪的是,我可以连接到另一台机器上的服务器!
在成功的方案中,idea.log将包含以下行:
INFO - ution.rmi.RemoteProcessSupport - Driver: PostgreSQL JDBC Driver 42.2.5
在我的机器上时,这是我发现的(连接到远程机器):
INFO - ution.rmi.RemoteProcessSupport -
此处没有驱动程序。 (使用MySQL进行测试,相同:缺少驱动程序,但在连接到本地主机时具有正确的驱动程序字段。)
连接失败时,IDEA没有提供任何有用的信息:
Connection to postgres@servername failed.
[08001] The connection attempt failed.
似乎IDEA在连接时未使用驱动程序文件?我该如何旋转?我花了很多时间在此上。真令人沮丧。
下面是完整的idea.log:
2019-04-10 13:53:58,200 [3956389] INFO - ution.rmi.RemoteProcessSupport - Port/ID: 45554/RemoteDriverImpl3db749c2
2019-04-10 13:53:58,224 [3956413] INFO - urce.DatabaseConnectionManager - Connecting as: postgres
2019-04-10 13:53:58,224 [3956413] INFO - urce.DatabaseConnectionManager - Connecting to: jdbc:postgresql://106.15.190.104:5432/postgres
2019-04-10 13:53:58,228 [3956417] INFO - ution.rmi.RemoteProcessSupport -
2019-04-10 13:53:59,964 [3958153] INFO - g.FileBasedIndexProjectHandler - Reindexing refreshed files: 372 to update, calculated in 44ms
2019-04-10 13:54:00,135 [3958324] INFO - .diagnostic.PerformanceWatcher - Reindexing refreshed files took 171ms; general responsiveness: ok; EDT responsiveness: ok
2019-04-10 13:54:00,745 [3958934] INFO - mponents.impl.stores.StoreUtil - saveProjectsAndApp took 49 ms
2019-04-10 13:54:26,475 [3984664] INFO - mponents.impl.stores.StoreUtil - saveProjectsAndApp took 36 ms
2019-04-10 13:55:00,583 [4018772] INFO - pi.util.registry.RegistryValue - Registry value 'ide.mac.allowDarkWindowDecorations' has changed to 'true'
2019-04-10 13:55:00,597 [4018786] INFO - tellij.openapi.util.IconLoader - replace '/general/notificationError.svg' with '/icons/general/notificationError.svg'
2019-04-10 13:59:23,296 [4281485] INFO - urce.DatabaseConnectionManager - Connecting as: postgres
2019-04-10 13:59:23,296 [4281485] INFO - urce.DatabaseConnectionManager - Connecting to: jdbc:postgresql://106.15.190.104:5432/postgres
2019-04-10 13:59:23,458 [4281647] INFO - mponents.impl.stores.StoreUtil - saveProjectsAndApp took 39 ms
2019-04-10 13:59:28,092 [4286281] INFO - mponents.impl.stores.StoreUtil - saveProjectsAndApp took 43 ms
2019-04-10 13:59:58,251 [4316440] INFO - pi.util.registry.RegistryValue - Registry value 'ide.mac.allowDarkWindowDecorations' has changed to 'true'
2019-04-10 14:00:01,087 [4319276] INFO - pi.util.registry.RegistryValue - Registry value 'ide.mac.allowDarkWindowDecorations' has changed to 'true'
2019-04-10 14:00:05,540 [4323729] INFO - ution.rmi.RemoteProcessSupport - "/Applications/IntelliJ IDEA.app/Contents/jdk/Contents/Home/jre/bin/java" -Djava.net.preferIPv4Stack=true -Djava.rmi.server.hostname=127.0.0.1 -Duser.timezone=UTC -Dfile.encoding=UTF-8 -classpath "/Applications/IntelliJ IDEA.app/Contents/lib/util.jar:/Applications/IntelliJ IDEA.app/Contents/lib/trove4j.jar:/Applications/IntelliJ IDEA.app/Contents/lib/groovy-all-2.4.15.jar:/Applications/IntelliJ IDEA.app/Contents/plugins/DatabaseTools/lib/jdbc-console.jar:/Applications/IntelliJ IDEA.app/Contents/plugins/DatabaseTools/lib/dekaf-single-2.0.0.387.jar:/Users/kevin/Library/Preferences/IntelliJIdea2019.1/jdbc-drivers/PostgreSQL/42.2.5/postgresql-42.2.5.jar" com.intellij.database.remote.RemoteJdbcServer org.postgresql.Driver
2019-04-10 14:00:05,745 [4323934] INFO - ution.rmi.RemoteProcessSupport - Port/ID: 42900/RemoteDriverImpla5fe3908
2019-04-10 14:00:05,767 [4323956] INFO - urce.DatabaseConnectionManager - No user name provided (may be in url)
2019-04-10 14:00:05,767 [4323956] INFO - urce.DatabaseConnectionManager - Connecting to: jdbc:postgresql://localhost:5432/postgres
2019-04-10 14:00:05,806 [4323995] INFO - pi.util.registry.RegistryValue - Registry value 'ide.mac.allowDarkWindowDecorations' has changed to 'true'
2019-04-10 14:00:15,474 [4333663] INFO - ution.rmi.RemoteProcessSupport - "/Applications/IntelliJ IDEA.app/Contents/jdk/Contents/Home/jre/bin/java" -Djava.net.preferIPv4Stack=true -Djava.rmi.server.hostname=127.0.0.1 -Duser.timezone=UTC -Dfile.encoding=UTF-8 -classpath "/Applications/IntelliJ IDEA.app/Contents/lib/util.jar:/Applications/IntelliJ IDEA.app/Contents/lib/trove4j.jar:/Applications/IntelliJ IDEA.app/Contents/lib/groovy-all-2.4.15.jar:/Applications/IntelliJ IDEA.app/Contents/plugins/DatabaseTools/lib/jdbc-console.jar:/Applications/IntelliJ IDEA.app/Contents/plugins/DatabaseTools/lib/dekaf-single-2.0.0.387.jar:/Users/kevin/Library/Preferences/IntelliJIdea2019.1/jdbc-drivers/PostgreSQL/42.2.5/postgresql-42.2.5.jar" com.intellij.database.remote.RemoteJdbcServer org.postgresql.Driver
2019-04-10 14:00:15,690 [4333879] INFO - ution.rmi.RemoteProcessSupport - Port/ID: 45818/RemoteDriverImpl78e32888
2019-04-10 14:00:15,713 [4333902] INFO - urce.DatabaseConnectionManager - Connecting as: postgre
2019-04-10 14:00:15,714 [4333903] INFO - urce.DatabaseConnectionManager - Connecting to: jdbc:postgresql://localhost:5432/postgres
2019-04-10 14:00:15,747 [4333936] WARN - urce.DatabaseConnectionManager - Connecting to: jdbc:postgresql://localhost:5432/postgres
2019-04-10 14:00:15,747 [4333936] WARN - urce.DatabaseConnectionManager - [08001] Connection to localhost:5432 refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.
2019-04-10 14:00:15,748 [4333937] WARN - lij.database.util.ErrorHandler - Connection to localhost:5432 refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.
java.sql.SQLException: Connection to localhost:5432 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:280)
at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:49)
at org.postgresql.jdbc.PgConnection.<init>(PgConnection.java:195)
at org.postgresql.Driver.makeConnection(Driver.java:454)
at org.postgresql.Driver.connect(Driver.java:256)
at com.intellij.database.remote.jdbc.impl.RemoteDriverImpl.connect(RemoteDriverImpl.java:41)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:357)
at sun.rmi.transport.Transport$1.run(Transport.java:200)
at sun.rmi.transport.Transport$1.run(Transport.java:197)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:196)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:573)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:834)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:688)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:687)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:283)
at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:260)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:161)
at java.rmi.server.RemoteObjectInvocationHandler.invokeRemoteMethod(RemoteObjectInvocationHandler.java:227)
at java.rmi.server.RemoteObjectInvocationHandler.invoke(RemoteObjectInvocationHandler.java:179)
at com.sun.proxy.$Proxy157.connect(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.intellij.execution.rmi.RemoteUtil.invokeRemote(RemoteUtil.java:175)
at com.intellij.execution.rmi.RemoteUtil.access$200(RemoteUtil.java:38)
at com.intellij.execution.rmi.RemoteUtil$RemoteInvocationHandler.invoke(RemoteUtil.java:271)
at com.sun.proxy.$Proxy158.connect(Unknown Source)
at com.intellij.database.dataSource.DatabaseConnectionEstablisher.connect(DatabaseConnectionEstablisher.java:199)
at com.intellij.database.dataSource.DatabaseConnectionEstablisher.tryConnect(DatabaseConnectionEstablisher.java:140)
at com.intellij.database.dataSource.DatabaseConnectionEstablisher.lambda$establishConnection$1(DatabaseConnectionEstablisher.java:90)
at com.intellij.database.dataSource.AsyncUtil.lambda$null$4(AsyncUtil.java:53)
at com.intellij.database.dataSource.AsyncUtil.lambda$underProgress$14(AsyncUtil.java:140)
at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:586)
at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:532)
at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:86)
at com.intellij.database.dataSource.AsyncUtil.underProgress(AsyncUtil.java:146)
at com.intellij.database.dataSource.AsyncUtil.underProgress(AsyncUtil.java:140)
at com.intellij.database.dataSource.AsyncUtil.lambda$captureIndicator$5(AsyncUtil.java:53)
at com.intellij.database.dataSource.AsyncUtil.lambda$null$11(AsyncUtil.java:109)
at com.intellij.database.dataSource.AsyncUtil.lambda$static$2(AsyncUtil.java:37)
at com.intellij.database.dataSource.AsyncUtil.lambda$thenComposeAsync$12(AsyncUtil.java:107)
at com.intellij.database.dataSource.AsyncUtil.lambda$processWhenComplete$13(AsyncUtil.java:125)
at java.util.concurrent.CompletableFuture.uniWhenComplete(CompletableFuture.java:760)
at java.util.concurrent.CompletableFuture$UniWhenComplete.tryFire(CompletableFuture.java:736)
at java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:474)
at java.util.concurrent.CompletableFuture.complete(CompletableFuture.java:1962)
at com.intellij.database.dataSource.AsyncUtil.lambda$processWhenComplete$13(AsyncUtil.java:125)
at java.util.concurrent.CompletableFuture.uniWhenComplete(CompletableFuture.java:760)
at java.util.concurrent.CompletableFuture.uniWhenCompleteStage(CompletableFuture.java:778)
at java.util.concurrent.CompletableFuture.whenComplete(CompletableFuture.java:2140)
at java.util.concurrent.CompletableFuture.whenComplete(CompletableFuture.java:110)
at com.intellij.database.dataSource.AsyncUtil.processWhenComplete(AsyncUtil.java:121)
at com.intellij.database.dataSource.AsyncUtil.lambda$null$11(AsyncUtil.java:109)
at com.intellij.openapi.application.impl.ApplicationImpl$1.run(ApplicationImpl.java:311)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.net.ConnectException: Connection refused (Connection refused)
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:589)
at org.postgresql.core.PGStream.<init>(PGStream.java:70)
at org.postgresql.core.v3.ConnectionFactoryImpl.tryConnect(ConnectionFactoryImpl.java:91)
at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:192)
at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:49)
at org.postgresql.jdbc.PgConnection.<init>(PgConnection.java:195)
at org.postgresql.Driver.makeConnection(Driver.java:454)
at org.postgresql.Driver.connect(Driver.java:256)
at com.intellij.database.remote.jdbc.impl.RemoteDriverImpl.connect(RemoteDriverImpl.java:41)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:357)
at sun.rmi.transport.Transport$1.run(Transport.java:200)
at sun.rmi.transport.Transport$1.run(Transport.java:197)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:196)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:573)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:834)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:688)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:687)
... 3 more