javaweb工程的一个功能无法实现请求帮忙
在写一个类似于校园图书馆的网页工程,在还书功能那里遇到麻烦了
用的是mysql5.6+myeclipse10 其他功能都运行良好
在DAO层
/
还书
/
public void backBook(int bkid, int stid) throws Exception{
// TODO Auto-generated method stub
/*删除记录*/
String sql = "delete record where bookid = " + bkid + " and studentid = " + stid;
this.openconnection();
this.conn.setAutoCommit(false);
Statement st = conn.createStatement();
st.executeUpdate(sql);
/*把书的数量+1*/
int oldnumber = 0;
String sql2 = "select booknumber from book where bookid = " + bkid;
PreparedStatement st2 = conn.prepareStatement(sql2);
ResultSet rs = st2.executeQuery();
if (rs.next())
oldnumber = rs.getInt("booknumber");
int newnumber = oldnumber + 1;
String sql3= "update book set booknumber = " + newnumber + " where bookid = " + bkid;
Statement st3 = conn.createStatement();
st3.executeUpdate(sql3);
this.closeResource();
}
在BIZ层
public void backBook(int bkid, int stid) throws Exception{
// TODO Auto-generated method stub
BookDao bkd = new BookDao();
bkd.backBook(bkid, stid);
}
SEVLET里
public void service(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String bookid = request.getParameter("bookid");
String studentid = request.getParameter("studentid");
int bkid = Integer.parseInt(bookid);
int stid = Integer.parseInt(studentid);
BookBiz bkb = new BookBiz();
try{
bkb.backBook(bkid, stid);
request.setAttribute("errMsg", "还书成功!");
request.getRequestDispatcher("error.jsp").forward(request, response);
}catch(Exception e){
Log.logger.error(e.getMessage());
request.setAttribute("errMsg", "还书失败,请稍后再试!");
request.getRequestDispatcher("error.jsp").forward(request, response);
}
}
运行的结果是,还书失败请稍后再试
但是没有报错,已经不知道如何改,求帮助
myeclipse java mysql tomcat sql
3DM06
9 years, 3 months ago