简体   繁体   English

为什么我无法在Eclipse中连接到mysql数据库?

[英]why can't I connect to mysql database in eclipse?

I'm unable to detect a MySQL connection when I'm in Eclipse. 在Eclipse中时,我无法检测到MySQL连接。 I currently run MySQL in a docker container and created a database y9 and a username of yannik . 我目前在泊坞窗容器中运行MySQL和创建的数据库y9和用户名yannik 在此处输入图片说明

在此处输入图片说明

I just want to know if there's anything I'm doing wrong here because I'm failing to connect to my local MySQL instance. 我只是想知道我在做什么,因为我无法连接到本地MySQL实例。

Stack-trace I get is 我得到的堆栈跟踪是

com.mysql.cj.jdbc.exceptions.CommunicationsException: 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 com.mysql.cj.jdbc.exceptions.SQLError.createCommunicationsException(SQLError.java:174)
    at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:64)
    at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:835)
    at com.mysql.cj.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:455)
    at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:240)
    at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:207)
    at org.eclipse.datatools.connectivity.drivers.jdbc.JDBCConnection.createConnection(JDBCConnection.java:328)
    at org.eclipse.datatools.connectivity.DriverConnectionBase.internalCreateConnection(DriverConnectionBase.java:105)
    at org.eclipse.datatools.connectivity.DriverConnectionBase.open(DriverConnectionBase.java:54)
    at org.eclipse.datatools.connectivity.drivers.jdbc.JDBCConnection.open(JDBCConnection.java:96)
    at org.eclipse.datatools.enablement.internal.mysql.connection.JDBCMySQLConnectionFactory.createConnection(JDBCMySQLConnectionFactory.java:28)
    at org.eclipse.datatools.connectivity.internal.ConnectionFactoryProvider.createConnection(ConnectionFactoryProvider.java:83)
    at org.eclipse.datatools.connectivity.internal.ConnectionProfile.createConnection(ConnectionProfile.java:359)
    at org.eclipse.datatools.connectivity.ui.PingJob.createTestConnection(PingJob.java:76)
    at org.eclipse.datatools.connectivity.ui.PingJob.run(PingJob.java:59)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
Caused by: com.mysql.cj.exceptions.CJCommunicationsException: 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:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:61)
    at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:105)
    at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:151)
    at com.mysql.cj.exceptions.ExceptionFactory.createCommunicationsException(ExceptionFactory.java:167)
    at com.mysql.cj.protocol.a.NativeSocketConnection.connect(NativeSocketConnection.java:91)
    at com.mysql.cj.NativeSession.connect(NativeSession.java:152)
    at com.mysql.cj.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:955)
    at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:825)
    ... 13 more
Caused by: java.net.ConnectException: 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 com.mysql.cj.protocol.StandardSocketFactory.connect(StandardSocketFactory.java:155)
    at com.mysql.cj.protocol.a.NativeSocketConnection.connect(NativeSocketConnection.java:65)
    ... 16 more

使eclipse中的JDBC CONNECTION URL遵循此模式。

jdbc:mysql://mysql_container:3306/db_nameserverTimezone=UTC&useSSL=false&allowPublicKeyRetrieval=true"&verifyServerCertificate=FALSE

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为什么我无法在Java中连接到MySQL数据库? - Why i can't connect to mysql database in java? 为什么我不能用 uwamp 连接到 mysql, - why can't I connect to mysql with uwamp, 为什么我不能使用MySQL Workbench连接到我的MySQL数据库? - Why can't I connect to my MySQL database using MySQL Workbench? 为什么我无法连接到我的sql数据库? 我收到错误消息:“无法通过套接字连接到本地MySQL服务器” - Why can't I connect to my sql database? I get the error message: “Can't connect to local MySQL server through socket” 为什么我可以使用WinSql连接到MySql,但不能在Eclipse的连接配置文件中连接? - Why can I connect to MySql with WinSql but not in a connection profile for Eclipse? MySQL 创建一个只能访问特定数据库的用户,为什么不能远程连接? - MySQL Create a user that can only access a specific database, why can't I connect remotely? 为什么我无法通过 JDBC 与 root 以外的其他数据库用户连接到 mysql docker 容器? - Why I can't connect to mysql docker container through JDBC with another database user than root? 无法连接到mysql数据库 - Can't connect to mysql database 无法连接到MySQL数据库? - Can't connect to MySQL database? 无法使用Mysql连接到数据库 - Can't connect to database with Mysql
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM