Illegal operation on empty result set.

ruoyinruoxian82432 2012-09-30 11:32:29
java菜鸟,
遇到一个问题请大家指教,感激不尽!

问题:
javax.servlet.ServletException: java.sql.SQLException: Illegal operation on empty result set.

源代码如下:
<%@ page language="java" import="java.util.*"
import="java.sql.Connection" import="java.sql.DriverManager"
import="java.sql.Statement" import="java.sql.ResultSet"
pageEncoding="gb2312"%>
<%@ page language="java" contentType="text/html;charset=GBK"%>
<html>
<head>
<title>修改图书信息</title>
</head>
<body>


<%
Class.forName("com.mysql.jdbc.Driver");
Connection conn=DriverManager.getConnection("jdbc:mysql://localhost:3306/mysql?","root","cxl");

Statement stmt=conn.createStatement();

String id=request.getParameter("id");
ResultSet rs=stmt.executeQuery("select * from bookinfo where id="+id);
rs.next();
%>
<form action="/update.jsp" method="post">
<table>
<caption>
修改图书信息
</caption>
<tr>

<th width="30%">
书名
</th>
<td width="30%">
<input name="book" type="text" value="<%rs.getStrin(2);%>">
</td>
<th width="30%">
价格:
</th>
<td width="30%">
<input name="book" type="text" value="<%rs.getStrin(3);%>">

</td>
</tr>
<tr>
<th colspan="2">
<input type="hidden" name="id" value="<%=id%>">
<input type="submit" value="修改">
<input type="reset" value="重置">
</th>
</tr>
</table>

</form>
<%
rs.close();
stmt.close();
conn.close();

%>
</body>
</html>
...全文
295 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
ruoyinruoxian82432 2012-10-02
  • 打赏
  • 举报
回复
while(rs.next){
rs.getString(1);
rs.getString(2);
rs.getString(3);
}
拆分了还是不行啊
liangtu 2012-10-01
  • 打赏
  • 举报
回复
在对rs进行拆分之前,先进行判断,看是否有内容。
ruoyinruoxian82432 2012-10-01
  • 打赏
  • 举报
回复
这我知道了 。可我要怎么改呢?谢谢了!
cowboyhn 2012-10-01
  • 打赏
  • 举报
回复
你的查询结果没有记录,所以rs.getString(2)出错了。
liangtu 2012-10-01
  • 打赏
  • 举报
回复
while(rs.hasNext()){
//对rs进行拆分
}
ruoyinruoxian82432 2012-10-01
  • 打赏
  • 举报
回复
谢谢各位了!可不可以说的详细点。现在还没解决。
Delphi 7.1 Update Release Notes=======================================================This file contains important supplemental and late-breakinginformation that may not appear in the main productdocumentation, and supersedes information contained in otherdocuments, including previously installed release notes.Borland recommends that you read this file in its entirety.NOTE: If you are updating a localized version of Delphi 7, visit the Borland Registered User web site to obtain a localized readme file that may contain important late- breaking information not included in this readme file.IMPORTANT: Delphi must be closed before installing this update. =====================================================CONTENTS * INSTALLING THIS UPDATE * UPDATING LOCALIZED VERSIONS OF DELPHI 7 * KNOWN ISSUES * ISSUES ADDRESSED BY THIS UPDATE - IDE - CORE DATABASE - DATASNAP - DBGO (ADO COMPONENTS) - dbExpress - dbExpress COMPONENTS AND DB VCL - dbExpress CORE DRIVER AND METADATA - dbExpress VENDOR ISSUES - dbExpress CERTIFICATION - WEB SNAP - ACTIVEX - COMPILER - RTL - VCL - THIRD PARTY - BOLD FOR DELPHI * VERIFYING THAT THE UPDATE WAS SUCCESSFUL * FILES INSTALLED BY THIS UPDATE =======================================================INSTALLING THIS UPDATE* This update can not be applied to Delphi 7 Architect Trial version. * This update can not be removed after it is installed.* You will need the original Delphi 7 installation CD available to install this update.* To install this update from the CD, insert the CD, and launch the d7_ent_upd1.exe file appropriate for your locale.* To install this update from the Web, double-click the self-executing installation file and follow the prompts. * The Delphi 7 documentation PDF files are available on the update CD.========================================================UPDATING LOCALIZED VERSIONS OF DELPHI 7* This update can be applied only to the English version of Delphi 7. There are separate updates for the German, French and Japanese ver

50,499

社区成员

发帖
与我相关
我的任务
社区描述
Java相关技术讨论
javaspring bootspring cloud 技术论坛(原bbs)
社区管理员
  • Java相关社区
  • 小虚竹
  • 谙忆
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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