Java-MySQL-查询操作
作者:互联网
public static List<Map<String, Object>> getWX(String cardid) throws SQLException {
String sql = "select * from baoxiu where cardid=? order by id desc";
PreparedStatement ptmt = conn.prepareStatement(sql);
ptmt.setString(1, cardid);
ResultSet rs = ptmt.executeQuery();
List<Map<String, Object>> list = new ArrayList<Map<String,Object>>() ;
while(rs.next()) {
HashMap<String, Object> map = new HashMap<String, Object>();
map.put("id", rs.getInt("id"));
map.put("bt", rs.getString("bt"));
map.put("pic", rs.getString("pic"));
map.put("nr", rs.getString("nr"));
map.put("wxry", rs.getString("wxry"));
map.put("zt", rs.getString("zt"));
map.put("name", rs.getString("name"));
map.put("addr", rs.getString("addr"));
map.put("cardid", rs.getString("cardid"));
list.add(map);
}
return list;
}
标签:map,Java,getString,rs,cardid,查询,MySQL,put,id 来源: https://blog.csdn.net/qq_34907078/article/details/104867249