📄 testdaoservlet.java
字号:
package hunnu.edu.cn.product.servlet;
import hunnu.edu.cn.product.common.db.dao.TB_STORAGEDao;
import hunnu.edu.cn.product.common.db.dao.implement.DaoFactory;
import hunnu.edu.cn.product.common.db.model.TB_STORAGE;
import hunnu.edu.cn.product.common.db.pool.DBPoolManager;
import java.io.IOException;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class TestDaoServlet extends HttpServlet
{
/**
*
*/
private static final long serialVersionUID = -34373581617694985L;
DBPoolManager manager;
/**
* Constructor of the object.
*/
public TestDaoServlet()
{
super();
}
/**
* Destruction of the servlet. <br>
*/
public void destroy()
{
super.destroy();
manager.destroyPool();
}
/**
* The doGet method of the servlet. <br>
*
* This method is called when a form has its tag value method equals to get.
*
* @param request the request send by the client to the server
* @param response the response send by the server to the client
* @throws ServletException if an error occurred
* @throws IOException if an error occurred
*/
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
DaoFactory factory=DaoFactory.newInstance();
TB_STORAGEDao dao=factory.newTB_STORAGEDao();
List<TB_STORAGE> ss=dao.getAll();
for(int i=0;i<ss.size();i++)
{
TB_STORAGE store=ss.get(i);
int ids[]=new int[1];
ids[0]=store.getFile_stg_id().intValue();
dao.removes(ids);
}
}
/**
* The doPost method of the servlet. <br>
*
* This method is called when a form has its tag value method equals to post.
*
* @param request the request send by the client to the server
* @param response the response send by the server to the client
* @throws ServletException if an error occurred
* @throws IOException if an error occurred
*/
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
doGet(request,response);
}
/**
* Initialization of the servlet. <br>
*
* @throws ServletException if an error occurs
*/
public void init() throws ServletException
{
manager=new DBPoolManager();
manager.getPool().init();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -