public List<Godness> query(List<Map<String,Object>> params) throws SQLException { Connection conn=DbUnit.getConnection(); StringBuilder sb=new StringBuilder(); sb.append("select * from godness where 1=1 "); if(params!=null && params.size()>0){ for(int i=0;i<params.size();i++){ Map<String,Object> map=params.get(i); sb.append(" and "+map.get("name")+" "+map.get("rela")+" "+map.get("value")+" "); } } PreparedStatement ps=conn.prepareStatement(sb.toString()); List<Map<String,Object>> params=new ArrayList<Map<String,Object>>(); Map<String,Object> param=new HashMap<String,Object> (); param.put("name", "user_name"); param.put("rela","="); param.put("value","'小花'"); params.add(param); List<Godness> g2= g.query(params);
添加回答
举报
0/150
提交
取消