Hi everyone,
I’m building a desktop application using Java and a MySQL Database. The MySQL database is hosted on HostGator cloud server.
I wrote the following code for database connection, but it isn't working.
Note: in the code, i changed localhost to the server Host Name and the 3306 to the server port numberpublic static Connection Connerdb() { try { Class.forName("com.mysql.jdbc.Driver"); Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/TestDB",root, " " ); return con; } catch (ClassNotFoundException | SQLException e){ JOptionPane.showMessageDialog(null, e); return null; } }