求jsp高手帮忙看看一段代码哪里出了问题,实在是没找出来。跪求~~~
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<%@ page language="java" contentType="text/html; charset=gb2312"
pageEncoding="gb2312" import="java.sql.*"%>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>???????</title>
</head>
<body>
<%request.setCharacterEncoding("gb2312"); //解决中文乱码
String bno=request.getParameter("bno");
String rno=request.getParameter("rno");
String bsum=null;
String rest=null;
String strDBDriver="com.microsoft.sqlserver.jdbc.SQLServerDriver";
String strDBUrl="jdbc:sqlserver://localhost:1433;DatabaseName=library";//library数据库名称
Class.forName(strDBDriver);
Connection con=DriverManager.getConnection(strDBUrl,"sa","11");
Statement s=con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
ResultSet rs=null;
String sql=null;
sql="select * from book where bno='"+bno+"'";
rs=s.executeQuery(sql);
int b=0;
int c=0;
while(rs.next()){bsum=rs.getString("bsum");c=1;
}
if(c==0){out.print("<script>alert('该书不存在!')</script>");%>
<script>window.location.href="bookborrow.jsp"</script>
<%}else { b=Integer.parseInt(bsum);
if(b==0){out.print("<script>alert('该书馆藏数目为0!')</script>");
%>
<script>window.location.href="bookborrow.jsp"</script>
<%}
else{ sql="select * from reader where rno='"+rno+"'";
rs=s.executeQuery(sql);
int d=0;
int f=0;
while(rs.next()){d=1;rest=rs.getString("rest");
f=Integer.parseInt(rest);;
}
if(d==0){out.print("<script>alert('该借书证号不存在!')</script>");%>
<script>window.location.href="bookborrow.jsp"</script>
<%}else{ b=b-1;f=f-1;
sql="update book set bsum='"+b+"' where bno='"+bno+"'";
s.executeUpdate(sql);
sql="update reader set rest='"+f+"' where rno='"+rno+"'";
s.executeUpdate(sql);
java.util.Date now=new java.util.Date();
String e=now.toLocaleString();
sql="insert into card1 (rno,bno,databorrow,datareturn) values ('"+rno+"','"+bno+"','"+e+"','未归还')";
s.executeUpdate(sql);
out.print("<script>alert('借阅成功!')</script>");%>
<script>window.location.href="bookborrow.jsp"</script>
<% }
}}%>
</body>
</html>