批量删除 JSP批量删除怎么写 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 1.用checkbox来做,首先要取到要删除的数据的所有传id,然后存到一个集合里面String[] ids = request.getParameterValues("chk"); int[] intIds=new int[ids.length]; for(int i=0;i<ids.length;++i){ intIds[i]=Integer.parseInt(ids[i]); }2.在数据访问层写具体的实现方法: public static void delAlot(int[] ids){ String tmp = ""; for(int i=0;i<ids.length;++i){ tmp+=ids[i]+","; } tmp = tmp.substring(0, tmp.length()-1); String sql = "delete from titles where id in("+ tmp +")"; //System.out.println(sql); updateBySql(sql);//此方法用于增删改 }private static void updateBySql(String sql){ Connection con = null; PreparedStatement pst = null; try{ con = DBHelper.getCon(); pst = con.prepareStatement(sql); pst.executeUpdate(); }catch(Exception e){ e.printStackTrace(); }finally{ DBHelper.closeStatement(pst); DBHelper.closeConnection(con); } } 怎么样去解析一个Jar文件 MP3解码的java源代码发布,绝无整蛊,不行请放声大骂 贪吃蛇的小问题 我是菜鸟,希望大家帮我下,有个程序通过编译了,没法运行 javah命令报错,不知道怎么解决了,跪求。。。 请问JAVA有没有中文的帮助文档? 关于java生成的exe文件不能运行的问题 请教:jsp中datetime问题 关于右键菜单的问题 JPadpro4.2中怎么配置VisualSourceSafe(或者其他版本控制器也可以) [求助]如何判断字符串是否已被sun.misc.BASE64Encoder加密? JAVA 中如何判断当前浏览器的语言
String[] ids = request.getParameterValues("chk");
int[] intIds=new int[ids.length];
for(int i=0;i<ids.length;++i){
intIds[i]=Integer.parseInt(ids[i]);
}
2.在数据访问层写具体的实现方法:
public static void delAlot(int[] ids){
String tmp = "";
for(int i=0;i<ids.length;++i){
tmp+=ids[i]+",";
}
tmp = tmp.substring(0, tmp.length()-1);
String sql = "delete from titles where id in("+ tmp +")";
//System.out.println(sql);
updateBySql(sql);//此方法用于增删改 }private static void updateBySql(String sql){
Connection con = null;
PreparedStatement pst = null;
try{
con = DBHelper.getCon();
pst = con.prepareStatement(sql);
pst.executeUpdate();
}catch(Exception e){
e.printStackTrace();
}finally{
DBHelper.closeStatement(pst);
DBHelper.closeConnection(con);
}
}