public List<Goddes> query(String name,String id) throws Exception{
List<Goddes>result=new ArrayList<Goddes>();
Connection cnn=DbUtil.getConnection();
StringBuilder sb=new StringBuilder();
sb.append(" select*from yingxiong ");
sb.append("where name like ? and id like ");
PreparedStatement ptmt=cnn.prepareStatement(sb.toString());
ptmt.setString(1, "%"+name+"%");
ptmt.setString(2, "%"+id+"%");
System.out.println(sb.toString());
ResultSet rs=ptmt.executeQuery();
Goddes g=null;
while(rs.next()){
g=new Goddes();
g.setId(rs.getInt("id"));
g.setname(rs.getString("name"));
g.setSex(rs.getString("sex"));
g.setAge(rs.getInt("age"));
result.add(g);
}
return result;
}
慕莱坞654189
相关分类