Question

I'm trying to connect mysql db in openshift from my application as below ,

new DriverManagerDataSource("jdbc:mysql://localhost/dbXXXX?autoReconnect=true", "usernameXXX", "pwdXXX");

However an error was thrown as

om.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.

Any idea , whats the reasonn

Was it helpful?

Solution

If this is a scaled application, then you need to also supply the port, as it won't be 3306. Otherwise try restarting the mysql cartridge, or try sshing into your gear, and use the "mysql" command to see if you can connect, also try using the environment variables for your connection instead of the actual values. Also, localhost is wrong, ssh into your gear and run "env | grep MYSQL" and you will see the values that you should use.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top