} if (log.isDebugEnabled()) { log.debug("Query: "+sql);
    public Collection query(Query query, String viewlogprivileges, String capriviledges) throws IllegalQueryException {        debug(">query()");        if (capriviledges == null || capriviledges.length() == 0 || !query.isLegalQuery()) {            throw new IllegalQueryException();        }        Connection con = null;        PreparedStatement ps = null;        ResultSet rs = null;        try {            // Construct SQL query.            con = JDBCUtil.getDBConnection(JNDINames.DATASOURCE);            // Different column names is an unforturnalte workaround because of Orcale, you cannot have a column named 'comment' in Oracle.            // The workaround 'comment_' was spread in the wild in 2005, so we have to use it so far.            String commentCol = LOGENTRYDATA_COL_COMMENT_OLD;            if (!JDBCUtil.columnExists(con, LOGENTRYDATA_TABLE, LOGENTRYDATA_COL_COMMENT_OLD)) {                log.debug("Using oracle column name 'comment_' in LogEntryData.");                commentCol = LOGENTRYDATA_COL_COMMENT_ORA;            }            String sql = "select "+LOGENTRYDATA_COL+", "+commentCol+" from "+LOGENTRYDATA_TABLE+" where ( "                    + query.getQueryString() + ") and (" + capriviledges + ")";            if (StringUtils.isNotEmpty(viewlogprivileges)) {                sql += " and (" + viewlogprivileges + ")";            }            ps = con.prepareStatement(sql);            //ps.setFetchDirection(ResultSet.FETCH_REVERSE);            ps.setFetchSize(LogConstants.MAXIMUM_QUERY_ROWCOUNT + 1);            // Execute query.            rs = ps.executeQuery();            // Assemble result.            ArrayList returnval = new ArrayList();            while (rs.next() && returnval.size() <= LogConstants.MAXIMUM_QUERY_ROWCOUNT) {                LogEntry data = new LogEntry(rs.getInt(1), rs.getInt(2), rs.getString(3), rs.getInt(4), rs.getInt(5), new Date(rs.getLong(6)), rs.getString(7),                 		rs.getString(8), rs.getInt(9), rs.getString(10));                if (logsigning) {                	TableProtectSessionLocal protect = protecthome.create();                	TableVerifyResult res = protect.verify(data);                	data.setVerifyResult(res.getResultConstant());                }                returnval.add(data);            }            return returnval;        } catch (Exception e) {            throw new EJBException(e);        } finally {            JDBCUtil.close(con, ps, rs);        }    } // query