当我尝试将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
这是我的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>
但连接时仍然出错...
任何帮助?
谢谢!
这是调试信息
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
答案 0 :(得分:0)
拒绝连接通常意味着没有服务正在侦听您尝试连接的服务器/端口:
netstat -a
,mysql
工具或带有上述IP /端口的工作台如果服务正在运行但没有侦听该IP /端口,那么您需要修复mysql服务器配置。查看文档。
如果服务正在运行并正在侦听该IP /端口,则表明存在网络问题;例如一些奇怪的防火墙。 (您永远不需要在127.0.0.1上进行任何防火墙....)