Hi,
I tried the same code on different machine with different MySQL server but the result is same "java.sql.SQLException: Communication link failure: null
"
what could be wrong with the following piece of code??
package test.db;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collection;
public class saveDB
{
private Connection conn;
String url="jdbc:mysql://192.168.1.157:3306/test";
String user="root";
String password="";
public saveDB() {
// open Database connection
try {
Class.forName("org.gjt.mm.mysql.Driver");
conn = DriverManager.getConnection(url,user,password);
System.out.println("*** Database connected");
} catch (ClassNotFoundException e) {
System.err.println("Can't instantiate Database Driver");
} catch (SQLException e) {
System.err.println("Can't connect to Database" +e);
}
}
Thank you
Vikas