我试图从java应用程序连接到我的数据库,但它拒绝连接,给出的错误是这个。
com.mysql.jdbc.exceptions.jdbc4.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 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:422)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:400)
at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1038)
at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:339)
at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2247)
at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2280)
at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2079)
at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:794)
at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:44)
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:422)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:400)
at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:399)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:325)
at java.sql.DriverManager.getConnection(DriverManager.java:664)
at java.sql.DriverManager.getConnection(DriverManager.java:247)
at MainTest.main(MainTest.java:23)
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:497)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:140)
Caused by: java.net.ConnectException: Connection refused
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:345)
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.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:214)
at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:298)
... 20 more
搜索我发现问题不是代码,而是连接到我的本地主机,因为我可以连接到localhost如果我去我的网络浏览器,只是去'localhost',我不能做一个telnet到localhost或127.0.0.1,它拒绝连接。
MacBook-Pro:etc alejandro-trabajo$ telnet localhost
Trying ::1...
telnet: connect to address ::1: Connection refused
Trying 127.0.0.1...
telnet: connect to address 127.0.0.1: Connection refused
Trying fe80::1...
telnet: connect to address fe80::1: Connection refused
telnet: Unable to connect to remote host
我已经尝试了在web上找到的所有东西,创建了一个新的“hosts”文件,刷新了dns,重新启动了apache服务器,取消了httpd中“ServerName localhost”的注释。配置文件。。。我真的不知道该怎么办。
PS:ping到localhost完美工作
MacBook-Pro:etc alejandro-trabajo$ ping localhost
PING localhost (127.0.0.1): 56 data bytes
64 bytes from 127.0.0.1: icmp_seq=0 ttl=64 time=0.048 ms
64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.075 ms
64 bytes from 127.0.0.1: icmp_seq=2 ttl=64 time=0.126 ms
64 bytes from 127.0.0.1: icmp_seq=3 ttl=64 time=0.121 ms
^C
--- localhost ping statistics ---
4 packets transmitted, 4 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 0.048/0.092/0.126/0.032 ms
也许这会有帮助。
~ $ ifconfig
...
en0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
ether 8c:85:90:94:fb:70
inet6 fe80::14aa:f1f1:ede3:b942%en0 prefixlen 64 secured scopeid 0x8
inet 192.168.1.100
~ $ telnet localhost 1234
Trying ::1...`enter code here`
telnet: connect to address ::1: Connection refused
Trying 127.0.0.1...
telnet: connect to address 127.0.0.1: Connection refused
telnet: Unable to connect to remote host
~ $ telnet 127.0.0.1 1234
Trying 127.0.0.1...
telnet: connect to address 127.0.0.1: Connection refused
telnet: Unable to connect to remote host
~ $ telnet 192.168.1.100 1234
Trying 192.168.1.100...
Connected to 192.168.1.100.
Escape character is '^]'.
This is a simple server
Selenium Webdriver(2.53)使用testNG和java(jdk 8)。Mozilla Firefox(46)在页面打开时立即崩溃,并显示错误消息: org.apache.http.conn.连接到127.0.0.1:7055[/127.0.0.1]失败:连接拒绝:连接
我正在使用winsock2编程一个服务器/客户机系统,当我将客户机连接到服务器名称或服务器IPv6地址时,它工作得很好。但是,当我使用服务器IPv4地址时,我从客户端中的connect()调用中得到错误“Connection referend”。 我如何也连接到服务器IPv4地址?我需要帮助,拜托。 多谢了。 根据用户Sorayuki给出的一个建议,我做了一些修改,只是为了检验他的理论是否正确。
问题内容: 在Digitalocean的Ubuntu 16.4中安装了Redis。 我已经通过编辑编辑将默认的redis服务器更改为我在Digitalocean中的IP 那之后,我试着和所有回应这样的: 在127.0.0.1:6379无法连接到Redis的:连接被拒绝 但是如果 我得到: 这正常吗?或者该怎么办? 问题答案: 您应该做什么取决于您希望它如何工作… 如果您希望能够通过任何网络接口连接
问题内容: 在ubuntu中尝试此mongo命令时,出现此错误。 我该如何纠正这个问题呢? 问题答案: 谢谢大家,我尝试运行mongo,但它最终没有运行,我发现我的硬盘上没有空间,我清空了一些空间,最后按照与mongodb docs中给出的安装步骤相同的安装步骤重新安装了它,最后重新启动了服务器它正在运行。 https://docs.mongodb.org/manual/tutorial/inst
我正在使用一个服务器:最新映像。我使用了“泊坞窗运行 -it --name=”redis2“ redis:1 bash” 命令并进入了容器。我看到默认情况下,redis 正在侦听端口:6379。 要解决此问题,请将“vm.overcommit_memory = 1”添加到 /etc/sysctl.conf 中,然后重新启动或运行命令 “sysctl vm.overcommit_memory=1”