1

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. I'm pretty sure I change all the port connection to my Java Web App from 3306 to 9094 but still having errors.

This is the error..

com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

This is my 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

<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
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555

1 Answers1

0

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. If not, start it.
  • Check that it is actually listening on 127.0.0.1:9094:
    • by using netstat -a,
    • by using the command line mysql tool or the workbench with the above IP / port
    • by attempting to connect to the above IP / port above using telnet or netcat or a similar tool.

If the service is running but not listening on that IP / port, then you need to fix the mysql server configuration. Check the documentation.

If the service is running and listening on that IP / port, it suggests there is a networking problem; e.g. some weird firewalling. (You should never need to do any firewalling on 127.0.0.1 ....)

Stephen C
  • 698,415
  • 94
  • 811
  • 1,216