Hello below is my jdbc code here I want to insert a record into remote machine, when Im using the same code with local Data Base server Im able to insert the record successfully. But When Im try with the remote machine it is throwing the following error.
And do please tell if the parameters that Im passing for creating connection are enough are need to add some thing else.
Errors:: When Im running the above code, getting below Exception
And also let me know if the connection details that Im passing in url are enough for making connection are need to add some thing else.
In order to connect to the remote sql server, only jdbc code is enough or should be developed as web application.
Someone Please tell me what I need to do, for resolving this problem!!
Thank you
public class JdbcTestClass {
public static void main(String [] args) throws SQLException
{
try {
Class.forName("com.mysql.jdbc.Driver");
Connection con= DriverManager.getConnection("jdbc:mysql://120....:3306/example","root","root");
Statement st = con.createStatement();
st.executeUpdate("insert into test.student values(9966,'pradeep',93);");
System.out.println("Record Inserted Successfuly :: ");
if(st != null)
{
st.close();
System.out.println("connection closed successfuly :: "+st);
}
if(con != null)
{
con.close();
}
}
catch (ClassNotFoundException e) {
e.printStackTrace();
System.out.println("Error In 1st try :: "+e);
}
}
}
Exception in thread "main" com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure Last packet sent to the server was 0 ms ago.