public CmsSqlConsoleResults execute(String sql, String pool, I_CmsReport report, List<Throwable> errors) {

        try {
            CmsMessageContainer message = Messages.get().container(Messages.RPT_SQLCONSOLE_BEGIN_0);
            report.println(message, I_CmsReport.FORMAT_HEADLINE);
            if (LOG.isInfoEnabled()) {
                LOG.info(message.key());
            }

            List<String> sentences = normalize(sql);
            if (sentences.size() < 1) {
                write(
                    report,
                    Messages.get().getBundle(report.getLocale()).key(Messages.ERR_SQLCONSOLE_NOTHING_TO_EXECUTE_0));
            } else {
                for (String sentence : sentences) {
                    if (!checkPermissions(sentence)) {
                        writeError(
                            report,
                            new CmsSecurityException(
                                Messages.get().container(
                                    Messages.ERR_SQLCONSOLE_NO_PERMISSIONS_EXEC_SENTENCE_1,
                                    sentence)));
                    } else {
                        if (!sentence.toUpperCase().startsWith("SELECT")
                            && !sentence.toUpperCase().startsWith("SHOW")) {
                            int res = executeUpdate(sentence, pool);
                            message = Messages.get().container(
                                Messages.RPT_SQLCONSOLE_ROWS_AFFECTED_1,
                                new Integer(res));
                            report.println(message);
                            if (LOG.isInfoEnabled()) {
                                LOG.info(message);
                            }
                        } else {
                            CmsSqlConsoleResults res = executeQuery(sentence, pool);
                            // writeTable(report, res);
                            message = Messages.get().container(
                                Messages.RPT_SQLCONSOLE_NUM_ROWS_RETRIEVED_1,
                                new Integer(res.getData().size()));
                            report.println(message);
                            if (LOG.isInfoEnabled()) {
                                LOG.info(message);
                            }
                            return res;
                        }
                    }
                }
            }
        } catch (Throwable e) {
            errors.add(e);
        } finally {
            CmsMessageContainer message = Messages.get().container(Messages.RPT_SQLCONSOLE_END_0);
            report.println(message, I_CmsReport.FORMAT_HEADLINE);
            if (LOG.isInfoEnabled()) {
                LOG.info(message.key());
            }
        }
        return null;
    }
public CmsSqlConsoleResults execute ( String sql , String pool , I_CmsReport report , List < Throwable > errors ) { try { CmsMessageContainer message = Messages . get ( ) . container ( Messages . RPT_SQLCONSOLE_BEGIN_0 ) ; report . println ( message , I_CmsReport . FORMAT_HEADLINE ) ; if ( LOG . isInfoEnabled ( ) ) { LOG . info ( message . key ( ) ) ; } List < String > sentences = normalize ( sql ) ; if ( sentences . size ( ) < 1 ) { write ( report , Messages . get ( ) . getBundle ( report . getLocale ( ) ) . key ( Messages . ERR_SQLCONSOLE_NOTHING_TO_EXECUTE_0 ) ) ; } else { for ( String sentence : sentences ) { if ( ! checkPermissions ( sentence ) ) { writeError ( report , new CmsSecurityException ( Messages . get ( ) . container ( Messages . ERR_SQLCONSOLE_NO_PERMISSIONS_EXEC_SENTENCE_1 , sentence ) ) ) ; } else { if ( ! sentence . toUpperCase ( ) . startsWith ( "SELECT" ) && ! sentence . toUpperCase ( ) . startsWith ( "SHOW" ) ) { int res = executeUpdate ( sentence , pool ) ; message = Messages . get ( ) . container ( Messages . RPT_SQLCONSOLE_ROWS_AFFECTED_1 , new Integer ( res ) ) ; report . println ( message ) ; if ( LOG . isInfoEnabled ( ) ) { LOG . info ( message ) ; } } else { CmsSqlConsoleResults res = executeQuery ( sentence , pool ) ; message = Messages . get ( ) . container ( Messages . RPT_SQLCONSOLE_NUM_ROWS_RETRIEVED_1 , new Integer ( res . getData ( ) . size ( ) ) ) ; report . println ( message ) ; if ( LOG . isInfoEnabled ( ) ) { LOG . info ( message ) ; } return res ; } } } } } catch ( Throwable e ) { errors . add ( e ) ; } finally { CmsMessageContainer message = Messages . get ( ) . container ( Messages . RPT_SQLCONSOLE_END_0 ) ; report . println ( message , I_CmsReport . FORMAT_HEADLINE ) ; if ( LOG . isInfoEnabled ( ) ) { LOG . info ( message . key ( ) ) ; } } return null ; }
Main method of this class. Executes the given sql query.<p>

This method also checks the permissions for executing sql sentences,
according to the <code>vfs-doctor.xml</code> configuration file.<p>

@param sql the sql query to execute
@param pool name of the db pool to use
@param report the report to write the output
@param errors a list to append errors to

@return a <code>{@link List}</code> if the sql is a SELECT sentence, or <code>null</code>.