⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 profiledconnection.java

📁 基于Jabber协议的即时消息服务器
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
            switch (type) {                case SELECT:                    addQuery(SELECT, sql, t2 - t1);                    break;                case UPDATE:                    addQuery(UPDATE, sql, t2 - t1);                    break;                case INSERT:                    addQuery(INSERT, sql, t2 - t1);                    break;                case DELETE:                    addQuery(DELETE, sql, t2 - t1);                    break;            }            return result;        }        /*         * This is one of the methods that we wish to time         */        public ResultSet executeQuery() throws SQLException {            long t1 = System.currentTimeMillis();            ResultSet result = pstmt.executeQuery();            long t2 = System.currentTimeMillis();            switch (type) {                case SELECT:                    addQuery(SELECT, sql, t2 - t1);                    break;                case UPDATE:                    addQuery(UPDATE, sql, t2 - t1);                    break;                case INSERT:                    addQuery(INSERT, sql, t2 - t1);                    break;                case DELETE:                    addQuery(DELETE, sql, t2 - t1);                    break;            }            return result;        }        /*         * This is one of the methods that we wish to time         */        public int executeUpdate() throws SQLException {            long t1 = System.currentTimeMillis();            int result = pstmt.executeUpdate();            long t2 = System.currentTimeMillis();            switch (type) {                case SELECT:                    addQuery(SELECT, sql, t2 - t1);                    break;                case UPDATE:                    addQuery(UPDATE, sql, t2 - t1);                    break;                case INSERT:                    addQuery(INSERT, sql, t2 - t1);                    break;                case DELETE:                    addQuery(DELETE, sql, t2 - t1);                    break;            }            return result;        }        // The following methods are from the Statement class - the        // SuperInterface of PreparedStatement        // without these this class won't compile        public boolean execute(String _sql) throws SQLException {            long t1 = System.currentTimeMillis();            boolean result = pstmt.execute(_sql);            long t2 = System.currentTimeMillis();            // determine the type of query            String sqlL = _sql.toLowerCase().trim();            if (sqlL.startsWith("insert")) {                addQuery(INSERT, _sql, t2 - t1);            }            else if (sqlL.startsWith("update")) {                addQuery(UPDATE, _sql, t2 - t1);            }            else if (sqlL.startsWith("delete")) {                addQuery(DELETE, _sql, t2 - t1);            }            else {                addQuery(SELECT, _sql, t2 - t1);            }            return result;        }        public int[] executeBatch() throws SQLException {            long t1 = System.currentTimeMillis();            int[] result = pstmt.executeBatch();            long t2 = System.currentTimeMillis();            switch (type) {                case SELECT:                    addQuery(SELECT, sql, t2 - t1);                    break;                case UPDATE:                    addQuery(UPDATE, sql, t2 - t1);                    break;                case INSERT:                    addQuery(INSERT, sql, t2 - t1);                    break;                case DELETE:                    addQuery(DELETE, sql, t2 - t1);                    break;            }            return result;        }        public ResultSet executeQuery(String _sql) throws SQLException {            long t1 = System.currentTimeMillis();            ResultSet result = pstmt.executeQuery(_sql);            long t2 = System.currentTimeMillis();            // determine the type of query            String sqlL = _sql.toLowerCase().trim();            if (sqlL.startsWith("insert")) {                addQuery(INSERT, _sql, t2 - t1);            }            else if (sqlL.startsWith("update")) {                addQuery(UPDATE, _sql, t2 - t1);            }            else if (sqlL.startsWith("delete")) {                addQuery(DELETE, _sql, t2 - t1);            }            else {                addQuery(SELECT, _sql, t2 - t1);            }            return result;        }        public int executeUpdate(String _sql) throws SQLException {            long t1 = System.currentTimeMillis();            int result = pstmt.executeUpdate(_sql);            long t2 = System.currentTimeMillis();            // determine the type of query            String sqlL = _sql.toLowerCase().trim();            if (sqlL.startsWith("insert")) {                addQuery(INSERT, _sql, t2 - t1);            }            else if (sqlL.startsWith("update")) {                addQuery(UPDATE, _sql, t2 - t1);            }            else if (sqlL.startsWith("delete")) {                addQuery(DELETE, _sql, t2 - t1);            }            else {                addQuery(SELECT, _sql, t2 - t1);            }            return result;        }    }    /**     * An implementation of the CallableStatement interface that wraps an     * underlying CallableStatement object and performs timings of the database     * queries.     */    class TimedCallableStatement extends CallableStatementWrapper {        private String sql;        private int type = SELECT;        public TimedCallableStatement(CallableStatement cstmt, String sql) {            super(cstmt);            this.sql = sql;            // determine the type of query            String sqlL = sql.toLowerCase().trim();            if (sqlL.startsWith("insert")) {                type = INSERT;            }            else if (sqlL.startsWith("update")) {                type = UPDATE;            }            else if (sqlL.startsWith("delete")) {                type = DELETE;            }            else {                type = SELECT;            }        }        public boolean execute() throws SQLException {            // Perform timing of this method.            long t1 = System.currentTimeMillis();            boolean result = cstmt.execute();            long t2 = System.currentTimeMillis();            switch (type) {                case SELECT:                    addQuery(SELECT, sql, t2 - t1);                    break;                case UPDATE:                    addQuery(UPDATE, sql, t2 - t1);                    break;                case INSERT:                    addQuery(INSERT, sql, t2 - t1);                    break;                case DELETE:                    addQuery(DELETE, sql, t2 - t1);                    break;            }            return result;        }        /*         * This is one of the methods that we wish to time         */        public ResultSet executeQuery() throws SQLException {            long t1 = System.currentTimeMillis();            ResultSet result = cstmt.executeQuery();            long t2 = System.currentTimeMillis();            switch (type) {                case SELECT:                    addQuery(SELECT, sql, t2 - t1);                    break;                case UPDATE:                    addQuery(UPDATE, sql, t2 - t1);                    break;                case INSERT:                    addQuery(INSERT, sql, t2 - t1);                    break;                case DELETE:                    addQuery(DELETE, sql, t2 - t1);                    break;            }            return result;        }        /*         * This is one of the methods that we wish to time         */        public int executeUpdate() throws SQLException {            long t1 = System.currentTimeMillis();            int result = cstmt.executeUpdate();            long t2 = System.currentTimeMillis();            switch (type) {                case SELECT:                    addQuery(SELECT, sql, t2 - t1);                    break;                case UPDATE:                    addQuery(UPDATE, sql, t2 - t1);                    break;                case INSERT:                    addQuery(INSERT, sql, t2 - t1);                    break;                case DELETE:                    addQuery(DELETE, sql, t2 - t1);                    break;            }            return result;        }        // The following methods are from the Statement class - the        // SuperInterface of PreparedStatement        // without these this class won't compile        public boolean execute(String _sql) throws SQLException {            long t1 = System.currentTimeMillis();            boolean result = cstmt.execute(_sql);            long t2 = System.currentTimeMillis();            // determine the type of query            String sqlL = _sql.toLowerCase().trim();            if (sqlL.startsWith("insert")) {                addQuery(INSERT, _sql, t2 - t1);            }            else if (sqlL.startsWith("update")) {                addQuery(UPDATE, _sql, t2 - t1);            }            else if (sqlL.startsWith("delete")) {                addQuery(DELETE, _sql, t2 - t1);            }            else {                addQuery(SELECT, _sql, t2 - t1);            }            return result;        }        public int[] executeBatch() throws SQLException {            long t1 = System.currentTimeMillis();            int[] result = cstmt.executeBatch();            long t2 = System.currentTimeMillis();            switch (type) {                case SELECT:                    addQuery(SELECT, sql, t2 - t1);                    break;                case UPDATE:                    addQuery(UPDATE, sql, t2 - t1);                    break;                case INSERT:                    addQuery(INSERT, sql, t2 - t1);                    break;                case DELETE:                    addQuery(DELETE, sql, t2 - t1);                    break;            }            return result;        }        public ResultSet executeQuery(String _sql) throws SQLException {            long t1 = System.currentTimeMillis();            ResultSet result = cstmt.executeQuery(_sql);            long t2 = System.currentTimeMillis();            // determine the type of query            String sqlL = _sql.toLowerCase().trim();            if (sqlL.startsWith("insert")) {                addQuery(INSERT, _sql, t2 - t1);            }            else if (sqlL.startsWith("update")) {                addQuery(UPDATE, _sql, t2 - t1);            }            else if (sqlL.startsWith("delete")) {                addQuery(DELETE, _sql, t2 - t1);            }            else {                addQuery(SELECT, _sql, t2 - t1);            }            return result;        }        public int executeUpdate(String _sql) throws SQLException {            long t1 = System.currentTimeMillis();            int result = cstmt.executeUpdate(_sql);            long t2 = System.currentTimeMillis();            // determine the type of query            String sqlL = _sql.toLowerCase().trim();            if (sqlL.startsWith("insert")) {                addQuery(INSERT, _sql, t2 - t1);            }            else if (sqlL.startsWith("update")) {                addQuery(UPDATE, _sql, t2 - t1);            }            else if (sqlL.startsWith("delete")) {                addQuery(DELETE, _sql, t2 - t1);            }            else {                addQuery(SELECT, _sql, t2 - t1);            }            return result;        }    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -