日期:2014-05-17 浏览次数:20872 次
public List<Product> getProductsByKeys(String keys){
final ArrayList<Product> products = new ArrayList<Product>();
String sql = "select * from product where name like '%"+keys+"%'";
System.out.println("sql:"+sql);
this.query(sql, new RowCallbackHandler() {
@Override
public void processRow(ResultSet rs) throws SQLException{
Product product = null;
while (rs.next()) {
product = new Product();
product.setId(rs.getString("id"));
product.setName(rs.getString("name"));
product.setPrice(rs.getString("price"));
System.out.println(product);
products.add(product);
}
}
});
return products;
}