如何使用 ResultSet: absolute(int row) in java 并使用 jstl 通过 jsp 以表格格式显示检索到的行

How to use ResultSet: absolute(int row) in java and dispaly retrieved rows in tabular format through jsp using jstl

我想通过使用 absolute(int row) 方法 从 ResultSet 中检索一些特定的行。我已经通过以下代码检索了表格格式的所有行:

public String[][] reference() {

        String a[][]=new String[46][2];
        int i=0;
        try
            { 
              con = getConnection();
              stmt = con.createStatement(rs.TYPE_SCROLL_SENSITIVE,rs.CONCUR_READ_ONLY);
              String sql="select logtime,beam_current from INDUS2_BDS.dbo.DCCT where logtime between '2014-10-10 07:17:00' and '2014-10-10 08:46:00'"+
              "and (beam_current like '%9.96' or beam_current like '%9.97' or beam_current like '%9.98' or  beam_current like '%9.99'  or beam_current like '%0' or beam_current like '%_0.01' or beam_current like '%_0.02' or beam_current like '%_0.03' or beam_current like '%_0.04' or beam_current like '%_0.05' or beam_current like '%_0.06')";
              stmt.executeQuery(sql);
              rs = stmt.getResultSet();

              while(rs.next()) 
              {

                      for(int j=0; j<2; j++)

                        {
                            a[i][j] = rs.getString(j+1);

                        }

                        i++;
                  }
           }

         catch( Exception e )
            {
                System.out.println("\nException "+e);
            }
            finally
            {
                closeConnection(stmt, rs, con);
            }
        return a;

现在我只想检索 3、4、11、13、23、27、28 行,尽管 all.How 可以这样做?

while之前定义int rowCounter=0;,在while体的末尾增加。

添加支票if (rowCounter==3 || rowCounter==4 ...) { //do your logic}