我正在制作一个访问mysql数据库的应用程序。我使用的是直接JDBC,而不是Web服务。模拟器访问没有问题,但实际设备给出了错误
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
这是连接类的代码(仅是连接方法)
public static Connection CONN(String name) {
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder()
.permitAll().build();
StrictMode.setThreadPolicy(policy);
Connection conn = null;
String ConnURL = null;
try {
Class.forName(classs);
conn = DriverManager.getConnection(url, un, password);
String stsql = "Select version()";
Toaster.toast(name);
//conn = DriverManager.getConnection(ConnURL);
} catch (SQLException se) {
Log.e("ERRO", se.getMessage());
Toaster.toast(se.getMessage());
System.out.println( se.getMessage() );
} catch (ClassNotFoundException e) {
Log.e("ERRO", e.getMessage());
} catch (Exception e) {
Log.e("ERRO", e.getMessage());
}
return conn;
}
有人可以给我一些帮助吗? 谢谢!