Scenario:
I had developed a Java/Swing/MySQL application. The following code works fine when both MySQL and Swing application are installed on the same computer.
Code:
public static Connection ConnectDB(){
try{
String userName = "root";
String password = "chen";
String url = "jdbc:mysql://localhost/javaandmysqltut";
Connection conn;
conn = DriverManager.getConnection (url, userName, password);
//JOptionPane.showMessageDialog(null,"Connection Established");
return conn;
}catch (Exception e){
JOptionPane.showMessageDialog(null,"Cannot connect to database server"+e);
return null;
}
}
Question:
Now, I want to install the application on multiple computers with a remote centralised database. I had replaced "locahost" in the connection parameter with ip address of the remote server. It can connect to the database but the application becomes very very slow and irresponsive.
What is the best/recommended way to do this?