Heading ##I have problem with my java application with database in mySQL and swing GUI.
When I've used localhost everything worked properly. But now I would like to share project with my friend and we decided to use server hosting. And here is a problem: Now application works very slow, after pressing a button I have to wait a few seconds for the program to respond. Also the connection is lost from time to time. I have no idea where can I find reason for the problem... Do somebody now what is the reason of this problem?
    private static Connection connection = null;
    Boolean error = false;
    private static String jdbcURL = "jdbc:mysql://host_name:3306/db_name";
    private static String user = "user";
    private static String password = "password";
    MakeConnection(Connection connection) throws SQLException{
        this.connection = connection;
    try {
        getConnection();
        System.out.print("Connected to the data base in MakeConnection");       
        }
        catch(Exception e) {
            error = true;
            System.out.print("Error in connection in MakeConnection consturctor" + e.getMessage());
            }
        finally{
        if(connection!=null)            connection.close();
        if(error)                       System.out.print("Problem with connection");
        else                            System.out.print("Program finished");
        }
    }
    public Connection getConnection() throws SQLException {
        try {
            Class.forName("com.mysql.cj.jdbc.Driver");
            connection = DriverManager.getConnection(jdbcURL,user,password);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return connection;
    }
}
Also sometimes application shows this error: The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
 
    