2

When i am trying to connect using the below function, it is showing "Communication link failure " from the application but not when i try login mysql directly. What can be the reason for this , and i am trying to access using root in the application.

   public static Connection getConnection() {
    Connection con = null;
    try {

        Class.forName("com.mysql.jdbc.Driver");

       con = DriverManager.getConnection("jdbc:mysql://localhost/test", "root", "12345");

    } //end try
    catch (Exception e) {

        e.printStackTrace();
    }
    return con;
}
Mohit H
  • 927
  • 3
  • 11
  • 26
  • Try to change the bind address attribute to "127.0.0.1" or 0.0.0.0 Also refer: http://stackoverflow.com/questions/6865538/solving-a-communications-link-failure-with-jdbc-and-mysql – Rahul Tripathi Sep 28 '15 at 13:53

0 Answers0