[英]Can't connect to mysql when I changed its port number rather than 3306
I kinda having an error when I tried to change mysql's port number to 9094 instead of 3306. But when I'm using 3306, I can get its data. 当我尝试将mysql的端口号更改为9094而不是3306时,我有点出错。但是当我使用3306时,可以获取其数据。 I'm pretty sure I change all the port connection to my Java Web App from 3306 to 9094 but still having errors.
我很确定我将与Java Web App的所有端口连接都从3306更改为9094,但是仍然有错误。
This is the error.. 这是错误。
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure com.mysql.jdbc.exceptions.jdbc4.CommunicationsException:通信链接失败
This is my jdbc.properties 这是我的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
This is my servlet 这是我的servlet
<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>
but still getting error on connection.. 但仍然在连接时出错。
Any help? 有什么帮助吗?
Thanks! 谢谢!
Here is the debug information 这是调试信息
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
Connection refused normally means that no service is listening on the server / port you are attempting to connect to: 通常,连接被拒绝意味着没有服务正在监听您要连接的服务器/端口:
netstat -a
, netstat -a
, mysql
tool or the workbench with the above IP / port mysql
工具或具有以上IP /端口的工作台 If the service is running but not listening on that IP / port, then you need to fix the mysql server configuration. 如果服务正在运行,但未在该IP /端口上侦听,则需要修复mysql服务器配置。 Check the documentation.
检查文档。
If the service is running and listening on that IP / port, it suggests there is a networking problem; 如果该服务正在该IP /端口上运行并正在侦听,则表明存在网络问题; eg some weird firewalling.
例如一些奇怪的防火墙。 (You should never need to do any firewalling on 127.0.0.1 ....)
(您永远不需要在127.0.0.1上做任何防火墙...。)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.