Logo Search packages:      
Sourcecode: mysql-connector-java version File versions  Download package

void com::mysql::jdbc::MysqlIO::explainSlowQuery ( byte[]  querySQL,
String  truncatedQuery 
) throws SQLException [inline, protected]

Runs an 'EXPLAIN' on the given query and dumps the results to the log

Parameters:
querySQL DOCUMENT ME!
truncatedQuery DOCUMENT ME!
Exceptions:
SQLException DOCUMENT ME!

Definition at line 963 of file MysqlIO.java.

References com::mysql::jdbc::ConnectionImpl::clientPrepareStatement(), com::mysql::jdbc::PreparedStatement::close(), com::mysql::jdbc::PreparedStatement::executeQuery(), com::mysql::jdbc::ConnectionImpl::getLog(), com::mysql::jdbc::log::Log::logWarn(), and com::mysql::jdbc::PreparedStatement::setBytesNoEscapeNoQuotes().

Referenced by com::mysql::jdbc::ServerPreparedStatement::serverExecute(), and sqlQueryDirect().

                            {
        if (StringUtils.startsWithIgnoreCaseAndWs(truncatedQuery, "SELECT")) { //$NON-NLS-1$

            PreparedStatement stmt = null;
            java.sql.ResultSet rs = null;

            try {
                stmt = (PreparedStatement) this.connection.clientPrepareStatement("EXPLAIN ?"); //$NON-NLS-1$
                stmt.setBytesNoEscapeNoQuotes(1, querySQL);
                rs = stmt.executeQuery();

                StringBuffer explainResults = new StringBuffer(Messages.getString(
                            "MysqlIO.8") + truncatedQuery //$NON-NLS-1$
                         +Messages.getString("MysqlIO.9")); //$NON-NLS-1$

                ResultSetUtil.appendResultSetSlashGStyle(explainResults, rs);

                this.connection.getLog().logWarn(explainResults.toString());
            } catch (SQLException sqlEx) {
            } finally {
                if (rs != null) {
                    rs.close();
                }

                if (stmt != null) {
                    stmt.close();
                }
            }
        } else {
        }
    }


Generated by  Doxygen 1.6.0   Back to index