简体   繁体   English

我更改端口号而不是3306时无法连接到mysql

[英]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: 通常,连接被拒绝意味着没有服务正在监听您要连接的服务器/端口:

  • Check that the MySQL service is running. 检查MySQL服务是否正在运行。 If not, start it. 如果没有,请启动它。
  • Check that it is actually listening on 127.0.0.1:9094: 检查它是否实际上在127.0.0.1:9094上侦听:
    • by using netstat -a , 通过使用netstat -a
    • by using the command line mysql tool or the workbench with the above IP / port 通过使用命令行mysql工具或具有以上IP /端口的工作台
    • by attempting to connect to the above IP / port above using telnet or netcat or a similar tool. 通过尝试使用telnet或netcat或类似工具连接到上述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.

相关问题 我可以通过RMI而非Http连接到SolrServer吗? - Can I connect to SolrServer via RMI rather than Http? 如何获得打印的1位数字而不是输入的原始数字? - How can I get the printed 1 digit number rather than the original number I typed in? 除非使用本地主机,否则无法使用Java连接到MySQL - Can't connect to MySQL using java unless its localhost 使用host:port调用jprofiler jpcontroller无法连接到jvm - jprofiler jpcontroller can't connect to jvm when called with host:port 如何使加载的jar使用自身资源而不是加载器? - How can I make a loaded jar use resources from itself rather than its loader? 我在我的IP地址上找不到我的端口号 - I can't find my port number at my IP address 无法连接到MySql - Can't connect to the MySql 插入父项及其子项时,Hibernate可以在插入子项时设置父项ID,而不必在之后进行更新吗? - When inserting a parent and its children can Hibernate set the parent id when inserting the child rather than having to update after? 在类而不是对象上进行反射时看不到声明的字段 - Can't see declared fields when doing reflection on a class rather than an object MailConnectException:无法连接到主机,端口-可以进行的POP3请求数量限制? - MailConnectException: Couldn't connect to host, port — Limit to number of POP3 requests that can be made?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM