当我收到此消息时New Host Connection established
连接是否正常?
我正在尝试在我的Android应用程序上连接本地数据库
try {
Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection(url, user, pass);
/* System.out.println("Databaseection success"); */
Log.i("MYLOG", "Message was not handled.1");
String result = "Database connection success\n";
Statement st = con.createStatement();
ResultSet rs = st.executeQuery("select * from depo");
ResultSetMetaData rsmd = rs.getMetaData();
Log.i("MYLOG", "Message was not handled.2");
while (rs.next()) {
result += rsmd.getColumnName(1) + ": " + rs.getInt(1) + "\n";
result += rsmd.getColumnName(2) + ": " + rs.getString(2) + "\n";
result += rsmd.getColumnName(3) + ": " + rs.getString(3) + "\n";
Log.i("MYLOG", "Message was not handled.3");
}
tv.setText(result);
} catch (Exception e) {
e.printStackTrace();
tv.setText(e.toString());
}
日志:
05-11 15:28:19.237 2337-2549/mysql.example.com.myapplication D/OpenGLRenderer: Use EGL_SWAP_BEHAVIOR_PRESERVED: true
[ 05-11 15:28:19.243 2337: 2337 D/ ]
HostConnection::get() New Host Connection established 0xafecbf90, tid 2337
[ 05-11 15:28:19.574 2337: 2549 D/ ]
HostConnection::get() New Host Connection established 0xae3e7600, tid 2549
05-11 15:28:19.578 2337-2549/mysql.example.com.myapplication I/OpenGLRenderer: Initialized EGL, version 1.4
答案 0 :(得分:-3)
我将minSdkVersion
更改为16而不是15,它可以正常工作。