I have an application on Openshift
I'm trying to connect
to MySQL DB
my code is :
private static final String URL = "jdbc:mysql://127.11.240.130:3306/"
+ DB_NAME;
public static String initConnection() {
if (connection == null) {
try {
Class.forName("com.mysql.jdbc.Driver");
connection = DriverManager.getConnection(URL, USER_NAME,
PASSWORD);
return "Connection Initialized!";
} catch (SQLException e) {
e.printStackTrace();
return e.getMessage();
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
return e.getMessage();
}
}
return "Connection Initialized!";
}
and in index.jsp
code is :
<p><% out.print(""+com.measyou.DbManager.initConnection()); %> </p>
this code gives me
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
and Caused by
:
Caused by: java.net.ConnectException: Connection refused: connect
I have referred This Link and This one as well, but Im unable to solve this problem. Please Help me in solving this one.