org.apache.commons.dbcp.DelegatingStatement is closed.是怎么回事?
有一个jsp页面,列出可供用户选择的若干文件,文件名前是复选框,用户可以选择文件,之后单击删除按钮对指定的文件进行删除.
jsp:
String fileids[]=request.getParameterValues("checkbox_file");
int len=uploadbean.DelByFileidBatch(fileids);
javabean中的方法:
public int DelByFileidBatch(String fileids[]) throws Exception
{
int len=fileids.length;
conn.setAutoCommit(false);
Statement stmt=conn.createStatement();
stmt.clearBatch();
for(int i=0;i<len;i++)
{
String strsql="delete from userfile where fileid='"+fileids[i]+"'";
stmt.addBatch(strsql);
String filepath=GetFilepathByFileid(fileids[i]);
System.out.println(filepath);
File f=new File(filepath);
if(f.exists()){
f.delete();
System.out.println(filepath);
}
}
stmt.executeBatch();
conn.commit();
stmt.close();
conn.close();
return len;
}
错误:
java.sql.SQLException: org.apache.commons.dbcp.DelegatingStatement is closed.
org.apache.commons.dbcp.DelegatingStatement.checkOpen(DelegatingStatement.java:136)
org.apache.commons.dbcp.DelegatingStatement.addBatch(DelegatingStatement.java:288)
com.cstmail.file.models.FileOperation.DelByFileidBatch(FileOperation.java:71)
org.apache.jsp.operation_jsp._jspService(operation_jsp.java:72)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)