android cannot connect MYSQL server
Error Note:
04-11 04:01:51.283: W/System.err(913): com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
04-11 04:01:51.296: W/System.err(913): The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
04-11 04:01:51.296: W/System.err(913): at java.lang.reflect.Constructor.constructNative(Native Method)
04-11 04:01:51.304: W/System.err(913): at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
MYSQL-DB Connection Code
private String CONNECTION_URL = "jdbc:mysql://192.168.2.10:8090/test";
private String user;
private String pass;
private java.sql.Statement stmt;
private java.sql.Connection conn;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Log.e(TAG, "step 1");
try {
Class.forName ("com.mysql.jdbc.Driver").newInstance ();
Log.e(TAG, "step 2");
} catch (InstantiationException e) {
Log.e(TAG, "Error 1");
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalAccessException e) {
Log.e(TAG, "error 2");
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ClassNotFoundException e) {
Log.e(TAG, "error 3");
// TODO Auto-generated catch block
e.printStackTrace();
}
try {Log.e(TAG, "step 3");
conn = DriverManager.getConnection(CONNECTION_URL, user, pass);
} catch (SQLException e) {
Log.e(TAG, "error 4");
// TODO Auto-generated catch block
e.printStackTrace();
}
try {Log.e(TAG, "step 4");
stmt = conn.createStatement();
} catch (SQLException e) {Log.e(TAG, "error 5");
// TODO Auto-generated catch block
e.printStackTrace();
}
}