public ResultSet executeQuery(String _sql) throws SQLException
        {
            Instant start = Instant.now();
            ResultSet result = cstmt.executeQuery(_sql);
            Instant end = Instant.now();

            // determine the type of query
            String sqlL = _sql.toLowerCase().trim();

            if (sqlL.startsWith("insert")) {
                addQuery(Type.insert, _sql, Duration.between(start, end));
            }
            else if (sqlL.startsWith("update")) {
                addQuery(Type.update, _sql, Duration.between(start, end));
            }
            else if (sqlL.startsWith("delete")) {
                addQuery(Type.delete, _sql, Duration.between(start, end));
            }
            else {
                addQuery(Type.select, _sql, Duration.between(start, end));
            }
            return result;
        }
An implementation of the CallableStatement interface that wraps an
underlying CallableStatement object and performs timings of the database
queries.
xmppserver/src/main/java/org/jivesoftware/database/ProfiledConnection.java