简单图书的增删改查


简单图书的增删改查。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。
资源截图
代码片段和文件信息
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.settingsorg.eclipse.jdt.core.prefs

     文件        500  2017-09-15 20:45  DeleteLibrary.settingsorg.eclipse.wst.common.component

     文件        414  2017-09-15 20:43  DeleteLibrary.settingsorg.eclipse.wst.common.project.facet.core.xml

     文件         49  2017-09-15 20:43  DeleteLibrary.settingsorg.eclipse.wst.jsdt.ui.superType.container

     文件          6  2017-09-15 20:43  DeleteLibrary.settingsorg.eclipse.wst.jsdt.ui.superType.name

     文件       2489  2017-09-15 22:08  DeleteLibrarysrccomcontrolDeleteBook.java

     文件       1981  2017-09-15 22:09  DeleteLibrarysrccomcontrolshowbook.java

     文件       2764  2017-09-15 22:09  DeleteLibrarysrccomcontrolUpdateBookCount.java

     文件       1580  2017-09-15 11:08  DeleteLibrarysrccomdaoDBUtil.java

     文件        778  2017-09-14 22:16  DeleteLibrarysrccomuserBook.java

     文件        110  2017-09-14 22:14  DeleteLibrarysrcConnection.properties

     文件       1614  2017-09-15 20:54  DeleteLibraryWebRootook_show.jsp

     文件        833  2017-09-15 19:46  DeleteLibraryWebRootindex.jsp

     文件         39  2017-09-15 20:43  DeleteLibraryWebRootmeta-INFMANIFEST.MF

     文件       2318  2017-09-15 22:08  DeleteLibraryWebRootWEB-INFclassescomcontrolDeleteBook.class

     文件       3218  2017-09-15 22:09  DeleteLibraryWebRootWEB-INFclassescomcontrolshowbook.class

     文件       2542  2017-09-15 22:09  DeleteLibraryWebRootWEB-INFclassescomcontrolUpdateBookCount.class

     文件       1994  2017-09-15 20:47  DeleteLibraryWebRootWEB-INFclassescomdaoDBUtil.class

     文件       1285  2017-09-15 20:47  DeleteLibraryWebRootWEB-INFclassescomuserBook.class

     文件        110  2017-09-14 22:14  DeleteLibraryWebRootWEB-INFclassesConnection.properties

     文件     960374  2017-09-15 20:47  DeleteLibraryWebRootWEB-INFlibmysql-connector-java-5.1.34-bin.jar

     文件       1533  2017-09-15 20:34  DeleteLibraryWebRootWEB-INFweb.xml

     文件       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.settingsorg.eclipse.jdt.core.prefs

     文件        482  2017-09-09 16:13  Library.settingsorg.eclipse.wst.common.component

............此处省略125个文件信息

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件举报,一经查实,本站将立刻删除。

发表评论

评论列表(条)