opendb2.sopendb 查看这个Bean ..mybbs.executeQuery(sql);方法。。在建立 createStatement()的时候,改成 createStatement(1005,1007)

解决方案 »

  1.   

    public Statement createStatement(int resultSetType,
                                     int resultSetConcurrency,
                                     int resultSetHoldability)
                              throws SQLException
    resultSetType - one of the following ResultSet constants: ResultSet.TYPE_FORWARD_ONLY, ResultSet.TYPE_SCROLL_INSENSITIVE, or ResultSet.TYPE_SCROLL_SENSITIVEresultSetConcurrency - one of the following ResultSet constants: ResultSet.CONCUR_READ_ONLY or ResultSet.CONCUR_UPDATABLEresultSetHoldability - one of the following ResultSet constants: ResultSet.HOLD_CURSORS_OVER_COMMIT or ResultSet.CLOSE_CURSORS_AT_COMMIT
      

  2.   

    首先多谢诸位的回答!问题还没解决,我的bean如下:
    //sopendb.java
    package opendb2;
    import java.sql.*;
    import java.io.*;
    import java.text.*;
    public class sopendb
    {   String sdbdriver="sun.jdbc.odbc.JdbcOdbcDriver";
    private Connection conn=null;
    private Statement stmt=null;
    String url="jdbc:odbc:myuser";  
        String user="sa";  
        String password="";  
    ResultSet  rs=null;
     public sopendb()
    {    try
         {
        Class.forName(sdbdriver);
     }
     catch(java.lang.ClassNotFoundException e)
     {
        System.err.println("加载:"+e.getMessage()) ;
      } 
         
    }
    public ResultSet executeQuery(String sql)
        {   rs=null;
        try

       conn=DriverManager.getConnection(url,user,password);
       stmt=conn.createStatement(1005,1007);
       rs=stmt.executeQuery(sql);
     }
     catch(SQLException ex)
     {
        System.err.println("数据库操作出错"+ex.getMessage()) ;
     }  
           return rs;
    }
    public void executeUpdate(String sql)
    {   stmt=null;
    rs=null; 
        try
    {
         conn=DriverManager.getConnection(url,user,password);
    stmt=conn.createStatement();
    stmt.executeUpdate(sql);
    stmt.close();
    conn.close();
    }
    catch(SQLException ex)
    {
        System.err.println("aq.executeQuery:"+ex.getMessage());
    }
    }
    public void closestmt()
    {   try
        {
       stmt.close();
    }
    catch(SQLException e)
    {
       e.printStackTrace();
    }
    }
    public void closeconn()
    {
        try
    {
      conn.close();
    }
    catch(SQLException e)
    {e.printStackTrace(); }
    }}
    为什么不支持rs.first()或rs.last()的用法呢?
      

  3.   

    你的mybbs,不是支持可移动结果集的Statement mybbs = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE)
      

  4.   

    你的mybbs,不是支持可移动结果集的Statement mybbs = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE)
      

  5.   

    加条广告(注:如果你不高兴,可以删除)
    招聘网页编程人员(1-2名)
    1-2年的网页编程经验
    语言:JSP,java,html,javascript
    请在简历中写明对以上语言的掌握程度以及学历.北京友联创新系统集成有限公司
    联系方式:
    010-62984859-8010王先生
    [email protected]