How to connect online mysql database to a java application?I have used below code to get the connection to my database.
private static Connection con;
        public static Connection connect() throws Exception {
        Class.forName("com.mysql.jdbc.Driver").newInstance();
        String url = "jdbc:mysql://host/database";
        con = DriverManager.getConnection(url, "username", "password");
        return con;
    }
but this gives me following error everytime.
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.
What should i do?
 
    