gpt4 book ai didi

java - 打开传出端口 (CENTOS)

转载 作者:行者123 更新时间:2023-11-30 00:58:52 24 4
gpt4 key购买 nike

当从Linux节点到Web服务器(在Java程序中)进行远程MySQl连接时,无法访问。我收到如下所示的错误。我可以使用 java 程序从本地计算机到 Web 服务器进行 MySQL 连接,并且 Web 服务器在远程 sql 列表中拥有我们的两个 IP。

我联系了我的 Linux 节点主机(连接到网络服务器的节点),他们告诉我打开传出端口 3306。我做了一些搜索并执行了这些终端命令:

iptables -A OUTPUT -o eth0 -p tcp --dport 3306 -j ACCEPT
service iptables restart

我做错了什么?我仍然无法连接到虚拟主机!

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:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1117)
at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:350)
at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2393)
at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2430)
at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2215)
at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:813)
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:526)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:399)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:334)
at java.sql.DriverManager.getConnection(DriverManager.java:571)
at java.sql.DriverManager.getConnection(DriverManager.java:215)
at com.sallesy.database.mysql.MySQLDatabaseConnection.connect(MySQLDatabaseConnection.java:44)
at com.sallesy.database.DatabaseConnection.createStatement(DatabaseConnection.java:109)
at com.sallesy.thread.engine.events.DonationProcessorEvent.processPending(DonationProcessorEvent.java:59)
at com.sallesy.thread.engine.events.DonationProcessorEvent.execute(DonationProcessorEvent.java:37)
at com.sallesy.thread.engine.GameEngine$1.run(GameEngine.java:41)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:304)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:178)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)

最佳答案

您还需要一个输入规则。

您允许通过端口 3306 进行输出,但不允许输入,服务器可以与您交谈,但听不到您的声音...

关于java - 打开传出端口 (CENTOS),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20314775/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com