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;	
	}

 

上一篇:java处理jdbc返回的数据


下一篇:java-如何将两个Kafka流结合在一起,并在具有Avro值的主题中产生结果