我最近更新了我的AVD和Eclipse ADT。更新後,我的android項目沒有正常運行。Android Mysql連接不工作
工作不正常的部分是我連接到mysql數據庫。
我的代碼:
String data= "";
String database(){
try{
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection conn=DriverManager.getConnection("jdbc:mysql://10.0.2.2:3306/sakila","root","warlock");
PreparedStatement stmt= conn.prepareStatement("Select * from actor");
ResultSet res=stmt.executeQuery();
int i=0;
while(res.next() && i <9)
{
data=data+res.getString("actor_id") + " " + res.getString("first_name") + "&";
System.out.println(data);
i++;
}
}
catch(Exception e)
{
System.out.println(e); }
TextView tv=(TextView) findViewById(R.id.textview);
tv.setText(data);
更新前,它的工作罰款。我沒有通過PHP連接。這可能是什麼錯誤?我今天早上做了更新。 5:30 IST
與Java控制檯應用程序代碼工作的? – Yahor10
不,我寫它來檢查我是否可以調試,因爲它給出輸出時,它在LogCat或控制檯上工作,我不記得哪一個正確 – Brooklyn