【发布时间】:2018-06-01 10:51:57
【问题描述】:
当我尝试将 mysql 的端口号更改为 9094 而不是 3306 时,我有点错误。但是当我使用 3306 时,我可以获取它的数据。我很确定我将与我的 Java Web App 的所有端口连接从 3306 更改为 9094,但仍然有错误。
这是错误..
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException:通信链路故障
这是我的 jdbc.properties
jdbc.driverClassName=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://127.0.0.1:9094/hnlmnl_db
jdbc.username=infordev
jdbc.password=infordev
这是我的小服务程序
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="${jdbc.driverClassName}" />
<property name="url" value="${jdbc.url}" />
<property name="username" value="${jdbc.username}" />
<property name="password" value="${jdbc.password}" />
</bean>
但仍然出现连接错误..
有什么帮助吗?
谢谢!
这里是调试信息
org.springframework.web.util.NestedServletException: Request processing failed; nested exception is
org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (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.)
org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is org.apache.commons.dbcp.SQLNestedException:
Cannot create PoolableConnectionFactory (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.)
org.apache.commons.dbcp.SQLNestedException: Cannot create
PoolableConnectionFactory (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.)
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.
java.net.ConnectException: Connection refused: connect
【问题讨论】:
-
你必须在 mysql 中更改它,它会自行检查这个线程:stackoverflow.com/questions/29866204/…
-
@AmrBerag 我在 my.ini 中更改了它的配置
-
@JamesAllen 你重启了mysql服务吗
-
你重启过等吗?
-
你有没有安装某种防火墙的机会?一些防病毒防火墙甚至会影响本地主机。