1:servlet调用:
String[] len=request.getParameterValues("check");
for(int i=0;i<len.length;i++)
{
Product sio=new Product();
ProductsService psi=new ProductsServiceImpl();
psi.deleteProducts(len);
}
2.方法:public void deleteProducts(String[] productID)
{
String sql=null;
Product pd=null;
Connection conn = null;
DBConnection db = null;
try {
db=new MSSQLConnection();
conn=db.getConnection();
Statement stmt=conn.createStatement();
StringBuffer sbSql = new StringBuffer();
for(int i=0;i<productID.length;i++)
{
sbSql.append("'") .append(productID[i]) .append("',");
sql="delete from product where productID in (" + sbSql.substring(0, sbSql.length() - 1) + ")";
int rst=stmt.executeUpdate(sql);
}
} catch (Exception e) {
e.printStackTrace();
}
finally
{
conn=null;
db.close();
}
}