?? brbookcontroller.java
字號:
import java.io.IOException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import library.DBConnection;
import library.admin;
public class brBookController extends Controller {
public void doPost (HttpServletRequest req,
HttpServletResponse res) throws ServletException, IOException {
String bookid=null, readerid=null,isbn=null;
HttpSession session = req.getSession();
bookid = req.getParameter("bookid");
readerid = req.getParameter("readerid");
isbn = req.getParameter("isbn");
session = req.getSession();
boolean br =true;
boolean br1 = true;
try{
DBConnection connection = DBConnection.Instance();
String sql = "select * from fakuan where readerid ='"+readerid+"'";
ResultSet w = null;
w = connection.runQuery(sql);
if(w.next()){
br =false;
}
sql = "select * from bookhavebr where findid ='"+bookid+"'";
w = connection.runQuery(sql);
if(w.next()){
br1 =false;
}
}catch(Exception e){
sendErrorRedirect(req, res, e);
}
try {
if(br == false){
res.sendRedirect("../searchbookresult.jsp?jieguo=failed1");
}else if(br1==false){
res.sendRedirect("../searchbookresult.jsp?jieguo=failed2");
}else{
String url ="jdbc:mysql://localhost/library?user=root&password=linux&useUnicode=true&characterEncoding=GB2312" ;
Connection conn= DriverManager.getConnection(url);
Statement stmt=conn.createStatement();
String sql = "insert into bookhavebr (findid,readerid,brdata,redata,xujie) " +
" values ('"+bookid+"','"+readerid+"',CURDATE(),DATE_ADD(CURDATE(), Interval 1 month),3"+")";
boolean rs=stmt.execute(sql);
sql = "update booktitle set isin = 'no' where findid = '"+bookid+"'";
rs=stmt.execute(sql);
sql = "update reader set yijieshu = yijieshu+1 where readerid = '"+readerid+"'";
rs=stmt.execute(sql);
sql = "update books set isinno = isinno-1 where isbn = '"+isbn+"'";
rs=stmt.execute(sql);
res.sendRedirect("../searchbookresult.jsp?jieguo=success");
}
} catch (Exception e2) {
sendErrorRedirect(req, res, e2);
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -