日期:2014-05-18  浏览次数:20857 次

求助!!请高手指点!(有时提示“无效的游标错误!”)
/*
  *下边是jsp页面文件
  */


<%@   page   contentType= "text/html;   charset=gb2312 "   language= "java "   import= "java.sql.*,bean.DBClass "   errorPage= " "   %>
<table   width= "75% "   align= "right "   border= "0 ">
<%
String   query= "SELECT   *   FORM   message ";
String   userId= " ";
String   message= " ";
String   date= " ";
DBClass   db=new   DBClass();
db.connect();
ResultSet   rt=db.executeQuery(query);
while(rt.next()){
userId=rt.getString( "userId ");
message=rt.getString( "message ");
date=rt.getString( "date ");
%>
<tr> <td>
留言者: <%=userId   %> &nbsp;&nbsp;&nbsp;&nbsp; <%=date   %> </td> </tr>
<tr> <%=message   %> </tr>
<%
}
db.closeConnection();
%>
<tr> <td>
<form   name= "form3 "   method= "post "   action= "/MsgBoard/UserComment ">
<div   align= "center "> 我要发言:(不超过50字) <font     color= "#FF0000 "   size= "-1 "> <%   if   (request.getAttribute( "errInf2 ")!=null){   %>
        <%=(String)request.getAttribute( "errInf2 ")   %>   <%   }   %> </font>
<p   align= "center ">
<textarea   name= "comment "   cols= "30 "   rows= "9 "   > </textarea> </p>
<p   align= "center ">
<input   name= "submit "   type= "submit "   value= "发布 "/> &nbsp;&nbsp;
<input   name= "reset "   type= "reset "   value= "重写 "/> </p>
</div>
</form> </td> </tr>
</table>


/*   DBClass   原代码,编译过   没有错误
  *   Designed   by   *****
  */


  package   bean;
 
  import   java.io.*;
  import   java.util.*;
  import   java.sql.*;
 
  public   class   DBClass
  {
  private   String   driver;
  private   String   url;
  private   String   username;
  private   String   password;
  private   Connection   connection;
  private   Statement   statement;
  private   String   message= " ";
  public   DBClass(){
  driver= "sun.jdbc.odbc.JdbcOdbcDriver ";
  url= "jdbc:odbc:msgboard ";
  username= " ";
  password= " ";
  connection=null;
  statement=null;
  message= " ";
  }
  public   DBClass(String   driver,String   url,String   username,String   password){
  this.driver=driver;
  this.url=url;
  this.username=username;
  this.password=password;