如何使用PhpStorm连接到Openshift数据库?

时间:2021-12-11 05:00:20

I've tried to connect to OpenShift MySQL database using the following settings:

我尝试使用以下设置连接到OpenShift MySQL数据库:

如何使用PhpStorm连接到Openshift数据库?

And

如何使用PhpStorm连接到Openshift数据库?

but I've got following error message:

但我有以下错误信息:

Connection to ConnectionNAME failed
java.sql.SQLException: Communications link failure

The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:525)
    at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
    at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1116)
    at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:344)
    at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2332)
    at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2369)
    at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2153)
    at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:792)
    at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:47)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:525)
    at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
    at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:381)
    at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:305)
    at com.intellij.persistence.jdbc.impl.RemoteDriverImpl.connect(RemoteDriverImpl.java:27)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:322)
    at sun.rmi.transport.Transport$1.run(Transport.java:177)
    at sun.rmi.transport.Transport$1.run(Transport.java:174)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.rmi.transport.Transport.serviceCall(Transport.java:173)
    at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:553)
    at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:808)
    at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:667)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
    at java.lang.Thread.run(Thread.java:722)
    at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:273)
    at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:251)
    at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:160)
    at java.rmi.server.RemoteObjectInvocationHandler.invokeRemoteMethod(RemoteObjectInvocationHandler.java:194)
    at java.rmi.server.RemoteObjectInvocationHandler.invoke(RemoteObjectInvocationHandler.java:148)
    at $Proxy74.connect(Unknown Source)
    at sun.reflect.GeneratedMethodAccessor78.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    at com.intellij.execution.rmi.RemoteUtil$RemoteInvocationHandler.invoke(RemoteUtil.java:206)
    at $Proxy75.connect(Unknown Source)
    at com.intellij.javaee.module.view.dataSource.LocalDataSource.getConnection(LocalDataSource.java:161)
    at com.intellij.javaee.module.view.dataSource.LocalDataSource.getConnection(LocalDataSource.java:133)
    at com.intellij.javaee.dataSource.DataSource.performJdbcOperation(DataSource.java:288)
    at com.intellij.javaee.dataSource.AbstractDataSource.refreshMetaData(AbstractDataSource.java:25)
    at com.intellij.javaee.module.view.dataSource.DataSourceUiUtil$3.run(DataSourceUiUtil.java:140)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl$TaskRunnable.run(ProgressManagerImpl.java:495)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl$6.run(ProgressManagerImpl.java:304)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl$2.run(ProgressManagerImpl.java:185)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:226)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl.runProcess(ProgressManagerImpl.java:175)
    at com.intellij.openapi.application.impl.ApplicationImpl$9$1.run(ApplicationImpl.java:676)
    at com.intellij.openapi.application.impl.ApplicationImpl$7.run(ApplicationImpl.java:449)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
    at java.util.concurrent.FutureTask.run(FutureTask.java:166)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
    at java.lang.Thread.run(Thread.java:722)
    at com.intellij.openapi.application.impl.ApplicationImpl$1$1.run(ApplicationImpl.java:152)
Caused by: java.net.ConnectException: Connection refused: connect
    at java.net.DualStackPlainSocketImpl.connect0(Native Method)
    at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:69)
    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.PlainSocketImpl.connect(PlainSocketImpl.java:157)
    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:241)
    at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:257)
    at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:294)
    at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2332)
    at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2369)
    at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2153)
    at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:792)
    at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:47)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:525)
    at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
    at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:381)
    at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:305)
    at com.intellij.persistence.jdbc.impl.RemoteDriverImpl.connect(RemoteDriverImpl.java:27)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:322)
    at sun.rmi.transport.Transport$1.run(Transport.java:177)
    at sun.rmi.transport.Transport$1.run(Transport.java:174)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.rmi.transport.Transport.serviceCall(Transport.java:173)
    at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:553)
    at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:808)
    at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:667)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
    at java.lang.Thread.run(Thread.java:722)

What's wrong in my actions?

我的行为有什么问题?

1 个解决方案

#1


3  

Looks like you're trying to connect to the gear's mysql instance remotely. We have tools for port-forwarding if you want to simplify that step: https://openshift.redhat.com/community/blogs/getting-started-with-port-forwarding-on-openshift
Otherwise, you'll need to use $UUID as the proxy user, and once connected, your local connection should then be 127.0.0.1:48729

看起来您正在尝试远程连接到gear的mysql实例。如果您想简化这个步骤,我们有端口转发工具:https://openshift.redhat.com/community/blogs/getting-stared -forward -forward -on-openshift,否则您需要使用$UUID作为代理用户,一旦连接完毕,您的本地连接应该是127.0.1:48 729

Looks like the value for your admin user is may not be correct. Please ssh onto your gear (rhc ssh {appName}) and run "env | grep OPENSHIFT_MYSQL" to list the variables storing your connectivity details.

看起来您的管理员用户的值可能不正确。请ssh到您的设备(rhc ssh {appName})并运行“env | grep OPENSHIFT_MYSQL”来列出存储您的连接细节的变量。

jdbc:mysql://127.11.103.129:3306/project assumes that:

jdbc:mysql:/ / 127.11.103.129:3306 /项目假设:

127.11.103.129 == $OPENSHIFT_MYSQL_DB_HOST
3306 == $OPENSHIFT_MYSQL_DB_PORT
project == $OPENSHIFT_APP_NAME  

If any of those values are incorrect, please use the correct values as well.

如果其中任何一个值不正确,请使用正确的值。

Feel free to post to the OpenShift forums as well: https://openshift.redhat.com/community/forums/openshift

也可以发布到OpenShift论坛:https://openshift.redhat.com/community/forums/openshift

#1


3  

Looks like you're trying to connect to the gear's mysql instance remotely. We have tools for port-forwarding if you want to simplify that step: https://openshift.redhat.com/community/blogs/getting-started-with-port-forwarding-on-openshift
Otherwise, you'll need to use $UUID as the proxy user, and once connected, your local connection should then be 127.0.0.1:48729

看起来您正在尝试远程连接到gear的mysql实例。如果您想简化这个步骤,我们有端口转发工具:https://openshift.redhat.com/community/blogs/getting-stared -forward -forward -on-openshift,否则您需要使用$UUID作为代理用户,一旦连接完毕,您的本地连接应该是127.0.1:48 729

Looks like the value for your admin user is may not be correct. Please ssh onto your gear (rhc ssh {appName}) and run "env | grep OPENSHIFT_MYSQL" to list the variables storing your connectivity details.

看起来您的管理员用户的值可能不正确。请ssh到您的设备(rhc ssh {appName})并运行“env | grep OPENSHIFT_MYSQL”来列出存储您的连接细节的变量。

jdbc:mysql://127.11.103.129:3306/project assumes that:

jdbc:mysql:/ / 127.11.103.129:3306 /项目假设:

127.11.103.129 == $OPENSHIFT_MYSQL_DB_HOST
3306 == $OPENSHIFT_MYSQL_DB_PORT
project == $OPENSHIFT_APP_NAME  

If any of those values are incorrect, please use the correct values as well.

如果其中任何一个值不正确,请使用正确的值。

Feel free to post to the OpenShift forums as well: https://openshift.redhat.com/community/forums/openshift

也可以发布到OpenShift论坛:https://openshift.redhat.com/community/forums/openshift