rs.absolute(index+1);
rs.relative(index);
    public List query(Admin admin, Query query, int index, int numberofrows) throws IllegalQueryException {        debug(">query(): ");        boolean authorizedtoanyprofile = true;        Connection con = null;        PreparedStatement ps = null;        ResultSet rs = null;        ArrayList returnval = new ArrayList();        GlobalConfiguration globalconfiguration = getRAAdminSession().loadGlobalConfiguration(admin);        RAAuthorization raauthorization = null;        String sqlquery = "select " + APPROVALDATA_COL + " from UserData where ";        // Check if query is legal.        if (query != null && !query.isLegalQuery())            throw new IllegalQueryException();        if (query != null)            sqlquery = sqlquery + query.getQueryString();        raauthorization = new RAAuthorization(admin, getRAAdminSession(), getAuthorizationSession());        String caauthstring = raauthorization.getCAAuthorizationString();        String endentityauth = "";        if (globalconfiguration.getEnableEndEntityProfileLimitations()){        	endentityauth = raauthorization.getEndEntityProfileAuthorizationString();        }        if (!caauthstring.trim().equals("") && query != null)            sqlquery = sqlquery + " AND " + caauthstring;        else            sqlquery = sqlquery + caauthstring;        if (globalconfiguration.getEnableEndEntityProfileLimitations()) {            if (caauthstring.trim().equals("") && query == null)                sqlquery = sqlquery + endentityauth;            else                sqlquery = sqlquery + " AND " + endentityauth;            if (endentityauth == null || endentityauth.trim().equals("")) {                authorizedtoanyprofile = false;            }        }        try {            if (authorizedtoanyprofile) {                // Construct SQL query.                con = JDBCUtil.getDBConnection(JNDINames.DATASOURCE);                ps = con.prepareStatement(sqlquery);                                // Execute query.                rs = ps.executeQuery();                rs.absolute(index+1);                // Assemble result.                while (rs.next() && returnval.size() <= numberofrows) {                	                    // Read the variables in order, some databases (i.e. MS-SQL)                     // seems to not like out-of-order read of columns (i.e. nr 15 before nr 1)                    int id = rs.getInt(1);                    int approvalid = rs.getInt(2);                    int approvaltype = rs.getInt(3);                    int endentityprofileId = rs.getInt(4);                    int caid = rs.getInt(5);                    String reqadmincertissuerdn = rs.getString(6);                    String reqadmincertserial = rs.getString(7);                    int status = rs.getInt(8);                    String approvaldatastring = rs.getString(9);                    String requestdatastring = rs.getString(10);                    long requestdate = rs.getLong(11);                    long expiredate = rs.getLong(12);                    int remainingapprovals = rs.getInt(13);                	ApprovalDataVO data = new ApprovalDataVO(id,approvalid,approvaltype,endentityprofileId,caid,                			                                 reqadmincertissuerdn, reqadmincertserial, status,                			                                 ApprovalDataUtil.getApprovals(approvaldatastring),                			                                 ApprovalDataUtil.getApprovalRequest(requestdatastring),                			                                 new Date(requestdate), new Date(expiredate), remainingapprovals);                 	returnval.add(data);                }            }            debug("<query()");            return returnval;        } catch (Exception e) {            throw new EJBException(e);        } finally {            JDBCUtil.close(con, ps, rs);        }    } // query 