资源简介
简单图书的增删改查。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。
代码片段和文件信息
package com.control;
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.dao.DBUtil;
import com.mysql.jdbc.PreparedStatement;
import com.mysql.jdbc.Statement;
public class DeleteBook extends HttpServlet {
/**
* Constructor of the object.
*/
public DeleteBook() {
super();
}
/**
* Destruction of the servlet.
*/
public void destroy() {
super.destroy(); // Just puts “destroy“ string in log
// Put your code here
}
/**
* The doGet method of the servlet.
*
* 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 {
doPost(request response);
}
/**
* The doPost method of the servlet.
*
* 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 {
int id=Integer.valueOf(request.getParameter(“id“));
Connection conn=null;
Statement stmt=null;
PreparedStatement pSta=null;
ResultSet rSta=null;
conn=DBUtil.open();
try {
pSta=(PreparedStatement)conn.prepareStatement(“delete from book where id=?“);
pSta.setInt(1id);
pSta.executeUpdate();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
finally{
DBUtil.close(stmt pSta rSta conn);
}
response.sendRedirect(“showbook“);
}
/**
* Initialization of the servlet.
*
* @throws ServletException if an error occurs
*/
public void init() throws ServletException {
// Put your code here
}
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 1187 2017-09-15 20:47 DeleteLibrary\.classpath
文件 1338 2017-09-15 20:47 DeleteLibrary\.project
文件 522 2017-09-15 20:43 DeleteLibrary\.settings\.jsdtscope
文件 364 2017-09-15 20:43 DeleteLibrary\.settings\org.eclipse.jdt.core.prefs
文件 500 2017-09-15 20:45 DeleteLibrary\.settings\org.eclipse.wst.common.component
文件 414 2017-09-15 20:43 DeleteLibrary\.settings\org.eclipse.wst.common.project.facet.core.xm
文件 49 2017-09-15 20:43 DeleteLibrary\.settings\org.eclipse.wst.jsdt.ui.superType.container
文件 6 2017-09-15 20:43 DeleteLibrary\.settings\org.eclipse.wst.jsdt.ui.superType.name
文件 2489 2017-09-15 22:08 DeleteLibrary\src\com\control\DeleteBook.java
文件 1981 2017-09-15 22:09 DeleteLibrary\src\com\control\showbook.java
文件 2764 2017-09-15 22:09 DeleteLibrary\src\com\control\UpdateBookCount.java
文件 1580 2017-09-15 11:08 DeleteLibrary\src\com\dao\DBUtil.java
文件 778 2017-09-14 22:16 DeleteLibrary\src\com\user\Book.java
文件 110 2017-09-14 22:14 DeleteLibrary\src\Connection.properties
文件 1614 2017-09-15 20:54 DeleteLibrary\WebRoot\book_show.jsp
文件 833 2017-09-15 19:46 DeleteLibrary\WebRoot\index.jsp
文件 39 2017-09-15 20:43 DeleteLibrary\WebRoot\me
文件 2318 2017-09-15 22:08 DeleteLibrary\WebRoot\WEB-INF\classes\com\control\DeleteBook.class
文件 3218 2017-09-15 22:09 DeleteLibrary\WebRoot\WEB-INF\classes\com\control\showbook.class
文件 2542 2017-09-15 22:09 DeleteLibrary\WebRoot\WEB-INF\classes\com\control\UpdateBookCount.class
文件 1994 2017-09-15 20:47 DeleteLibrary\WebRoot\WEB-INF\classes\com\dao\DBUtil.class
文件 1285 2017-09-15 20:47 DeleteLibrary\WebRoot\WEB-INF\classes\com\user\Book.class
文件 110 2017-09-14 22:14 DeleteLibrary\WebRoot\WEB-INF\classes\Connection.properties
文件 960374 2017-09-15 20:47 DeleteLibrary\WebRoot\WEB-INF\lib\mysql-connector-java-5.1.34-bin.jar
文件 1533 2017-09-15 20:34 DeleteLibrary\WebRoot\WEB-INF\web.xm
文件 1187 2017-09-09 16:17 Library\.classpath
文件 1332 2017-09-09 18:26 Library\.project
文件 522 2017-09-09 16:13 Library\.settings\.jsdtscope
文件 364 2017-09-09 16:13 Library\.settings\org.eclipse.jdt.core.prefs
文件 482 2017-09-09 16:13 Library\.settings\org.eclipse.wst.common.component
............此处省略125个文件信息
评论
共有 条评论