急求救!!各位高手,有关修改更新数据库我遇到了以下问题,请帮忙

hxc0906 2003-11-11 09:49:56
原代码如下:
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<%@ include file ="Conn.jsp" %>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body>
<% String bno=request.getParameter("bno");
if(bno==null)
{
rs=stmt.executeQuery("select * from book");
}
%>
<table width="483" border="0" cellpadding="0" cellspacing="0" bgcolor="#eff8f7">
<tr>
<td width="27"> </td>
<td colspan="2"><img src="image/2b.gif" width="456" height="17"></td>
</tr>
<tr>
<td height="16"> </td>
<td width="102" rowspan="2" bgcolor="#eff8f7"></div> </td>
<td width="354" rowspan="2" bgcolor="#eff8f7"> </td>
</tr>
<tr>
<td height="16"> </td>
</tr>
<tr>
<td height="22"> </td>
<td bgcolor="#eff8f7"></td>
<td bgcolor="#eff8f7"><strong><font color="#999999">请输入你要修改的数目编号或书名</font></strong></td>
</tr>
<tr>
<td height="24" rowspan="5"> </td>
<td height="19" bgcolor="#eff8f7"><div align="right"><font color="#666666">编号</font></div></td>
<td rowspan="5" bgcolor="#eff8f7"><form name="form1" method="post" action="">
<p>
<input type="text" name="bno">
</p>
<p>
<input type="text" name="bname">
</p>
<p>
<input type="submit" name="Submit" value="确定">
</p>
</form></td>
</tr>
<tr>
<td bgcolor="#eff8f7"><div align="right"></div></td>
</tr>
<tr>
<td bgcolor="#eff8f7"><div align="right"><font color="#666666">书名</font></div></td>
</tr>
<tr>
<td bgcolor="#eff8f7"> </td>
</tr>
<tr>
<td bgcolor="#eff8f7"> </td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td height="20"> </td>
<td colspan="2"><img src="image/bb.gif" width="456" height="20"></td>
</tr>
</table>
<table width="483" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="25"><div align="center"><font color="#666666" size="2" face="幼圆">---------------------709&靓女工作室-------------------</font></div></td>
</tr>
</table>
<%

rs=stmt.executeQuery("select * from book");
else
{
if(!rs.next())
{
%>
<%= bno%>not fount!!!
<A href = change.jsp>try to change again</A>
<%
}
else
{
%>
<FORM action="change.jsp" method=POST>
<table>
<tr><td><p>书编号:</p></td><td><%= bno%></td></tr>
<tr><td><p>书名:</p></td><td><input type="text" size=26 name=bname value="<%=rs.getString("bname")%>"></td></tr>
<tr><td><p>出版社:</p></td><td><input type="text" size=26 name=bpress value="<%=rs.getString("bpress")%>"></td></tr>
<tr><td><p>作者:</p></td><td><input type="text" size=26 name=bauthor value="<%=rs.getString("bauthor")%>"></td></tr>
<tr><td><p>国家编号:</p></td><td><input type="text" size=26 name=countryID value="<%=rs.getString("countryID")%>"></td></tr>
<tr><td><p>书价:</p></td><td><input type="text" size=26 name=bprice value="<%=rs.getString("bPrice")%>"></td></tr>
<input type="submit" value="change" name=submit2>
</table>
</FORM>
<%
}
}
String strDel = "DELETE FROM book WHERE bno = '" + bno+"'"; //删除旧数据的SQL叙述
stmt.executeUpdate(strDel);
String str1=(request.getParameter("bname"));
byte[] tem1=str1.getBytes("ISO8859_1");
str1=new String(tem1);
String str2=(request.getParameter("bpress"));
byte[] tem2=str2.getBytes("ISO8859_1");
str2=new String(tem2);
String str3=(request.getParameter("bauthor"));
byte[] tem3=str3.getBytes("ISO8859_1");
str3=new String(tem3);
String str4=(request.getParameter("countryID"));
String str5=(request.getParameter("bprice"));
String strSQL = "INSERT INTO book(bname, bpress,bauthor,countryID, bprice) Values ('" +str1+ "','" +str2 +"','" + str3 + "','" + str4 + "'," + str5 + ")";
//String strUpd1="UPDATE book SET bname='"+bname+"'where bno ='"+bno+"'";
//stmt.executeUpdate(strUp1);
//String strUpd2="UPDATE book SET bpress='"+bpress+"'where bno ='"+bno+"'";
//stmt.executeUpdate(strUp2);
//String strUpd3="UPDATE book SET bauthor='"+bauthor+"'where bno ='"+bno+"'";
//stmt.executeUpdate(strUp3);
//String strUpd4="UPDATE book SET countryID='"+countryID+"'where bno ='"+bno+"'";
//stmt.executeUpdate(strUp4);
//String strUpd5="UPDATE book SET bprice="+bprice+"where bno ='"+bno+"'";
//stmt.executeUpdate(strUp5);
stmt.executeUpdate(strSQL); //利用SQL叙述将数据新增至数据库
strSQL = "SELECT * FROM book WHERE bno = '" + bno+ "'"; //建立查询书籍数据的SQL字串
rs = stmt.executeQuery(strSQL); //开启ResultSet变量
rs.next(); //移至第一笔记录
%>
<CENTER>
<H3><P><FONT SIZE = 5 COLOR = red>
<%= bno %>
</FONT>
修改后的详细数据如下:</P></H3>
<TABLE bgcolor=DodgerBlue>
<TR bgcolor=SkyBlue><TD bgcolor=SkyBlue><B>书籍编号
</B></TD><TD bgcolor=LightGoldenrodYellow><B>
<%= rs.getString("bno") %></B></TD></TR>
<TR bgcolor=SkyBlue><TD bgcolor=SkyBlue><B>书籍名称
</B></TD><TD bgcolor=LightGoldenrodYellow><B>
<%= rs.getString("bname") %></B></TD></TR>
<TR bgcolor=SkyBlue><TD bgcolor=SkyBlue><B>出版日期
</B></TD><TD bgcolor=LightGoldenrodYellow><B>
<%= rs.getString("bpdate") %></B></TD></TR>
<TR bgcolor=SkyBlue><TD bgcolor=SkyBlue><B>作 者
</B></TD><TD bgcolor=LightGoldenrodYellow><B>
<%= rs.getString("bauthor") %></B></TD></TR>
<TR bgcolor=SkyBlue><TD bgcolor=SkyBlue><B>价 格
</B></TD><TD bgcolor=LightGoldenrodYellow>
<FONT SIZE = 4 COLOR = red><B>
<%= rs.getString("bprice") %></B></FONT></B>
</TD></TR>

</TABLE>

</body>
</html>

编译后的错误提示如下:

org.apache.jasper.JasperException: Unable to compile class for JSP

An error occurred at line: 72 in the jsp file: /709/myweb/change.jsp

Generated servlet error:
[javac] Compiling 1 source file

D:\Program Files\Apache Group\Tomcat 4.1\work\Standalone\localhost\_\709\myweb\change_jsp.java:207: 'else' without 'if'
else
^
1 error
...全文
33 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
ExplorerCSharp 2003-11-11
  • 打赏
  • 举报
回复
<% String bno=request.getParameter("bno");
if(bno==null)
{
rs=stmt.executeQuery("select * from book");
}
%>


<%

rs=stmt.executeQuery("select * from book");*********
else
{
if(!rs.next())
{
%>

看看你的代码,把加”*********“删掉看看

81,092

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧