我想在sql server中从我的数据库影响我的textview数据但是我没有到达这个,这是我的代码
SpinCom.setOnItemSelectedListener(new OnItemSelectedListener(){
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
try {
List<Model> list = new ArrayList<Model>();
String descript = "";
String query = "select * from centre where commune = '" + SpinCom + "'";
PreparedStatement stmt;
ResultSet rs;
Connection con = connectionClass.CONN();
stmt = con.prepareStatement(query);
rs = stmt.executeQuery();
// ResultSetMetaData rsmd = rs.getMetaData();
ArrayList<String> data = new ArrayList<String>();
// ListView adapter = new ListView(this, list);
// listView.setAdapter(adapter);
while (rs.next()) {
String id2 = rs.getString("commune");
data.add(id2);
Model obj = new Model();
obj.Ncentre(rs.getInt(1));
obj.Ndescript(rs.getString(2));
obj.Nrespons(rs.getString(3));
list.add(obj);
Showdescription.setText(list.get(position).Ncentre());
Showresponsable.setText(list.get(position).Ndescript());
Showquartier.setText(list.get(position).Nrespons());
}
} catch (SQLException e) {
e.printStackTrace();
}
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
});
我想要你的帮助
答案 0 :(得分:-1)
建议使用Web服务从任何远程服务器获取数据,否则您无法从服务器获取数据