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;
}
