public ResultSet equipmentList(Connection con,EquipmentType equipmentType) throws Exception{
StringBuffer sb=new StringBuffer("select * from t_equipmenttype");
//System.out.print(equipmentType.getEquipmentTypeName());
if(StringUtil.isNotEmpty(equipmentType.getEquipmentTypeName())){
sb.append(" and equipmentTypeName like '%"+equipmentType.getEquipmentTypeName()+"%'");
}
PreparedStatement pstmt=con.prepareStatement(sb.toString().replaceFirst("and", "where"));
System.out.print(pstmt);
return pstmt.executeQuery();
}
挺好,学习到了.