日期:2014-05-16 浏览次数:20449 次
//保存销售信息列表到数据库 public boolean saveClothSaleInfo(List<ClothSaleInfoVO> saleInfoList){ Connection conn = null; PreparedStatement pstm = null; String sql = "insert into cloth_sale_info(sale_number,cloth_id,user_id) values(?,?,?)"; try { conn = DBUtil.getConnection(); pstm = conn.prepareStatement(sql); for (ClothSaleInfoVO clothSaleInfo : saleInfoList) { pstm.setLong(1, clothSaleInfo.getSaleNumber()); pstm.setInt(2, clothSaleInfo.getClothId()); pstm.setInt(3, clothSaleInfo.getUserId()); pstm.addBatch(); } pstm.executeBatch(); return true; } catch (SQLException e) { e.printStackTrace(); return false; } finally { DBUtil.close(conn, pstm, null); } }
?