Package com.alibaba.druid.proxy.jdbc

Examples of com.alibaba.druid.proxy.jdbc.ConnectionProxy


            return chain.statement_executeUpdate(statement, sql, autoGeneratedKeys);
        }

        long startMillis = System.currentTimeMillis();

        ConnectionProxy connection = statement.getConnectionProxy();
        {
            TraceEvent event = new TraceEvent("StatementExecuteUpdateBefore", new Date(startMillis));
            event.putContext(TRACE_CONN_INFO, connection.getProperties().clone());
            event.putContext(TRACE_CONN_CONNECTED_TIME, connection.getConnectedTime());
            event.putContext(TRACE_CONN_ID, connection.getId());
            event.putContext(TRACE_STMT_ID, statement.getId());
            event.putContext(TRACE_STMT_SQL, sql);
            event.putContext("stmt.autoGeneratedKeys", autoGeneratedKeys);

            fireEvent(event);
        }

        try {
            int updateCount = chain.statement_executeUpdate(statement, sql, autoGeneratedKeys);

            long timespan = System.currentTimeMillis() - startMillis;
            {
                TraceAfterEvent event = new TraceAfterEvent("StatementExecuteUpdateAfter", new Date(startMillis),
                                                            timespan);
                event.putContext(TRACE_CONN_INFO, connection.getProperties().clone());
                event.putContext(TRACE_CONN_CONNECTED_TIME, connection.getConnectedTime());
                event.putContext(TRACE_CONN_ID, connection.getId());
                event.putContext(TRACE_STMT_ID, statement.getId());
                event.putContext(TRACE_STMT_SQL, sql);
                event.putContext("stmt.autoGeneratedKeys", autoGeneratedKeys);
                event.putContext(TRACE_STMT_UPDATE_COUNT, updateCount);
                fireEvent(event);
            }

            return updateCount;
        } catch (SQLException ex) {
            {
                TraceErrorEvent event = new TraceErrorEvent("StatementExecuteUpdateError", new Date(startMillis), ex);
                event.putContext(TRACE_CONN_INFO, connection.getProperties().clone());
                event.putContext(TRACE_CONN_CONNECTED_TIME, connection.getConnectedTime());
                event.putContext(TRACE_CONN_ID, connection.getId());
                event.putContext(TRACE_STMT_ID, statement.getId());
                event.putContext(TRACE_STMT_SQL, sql);
                event.putContext("stmt.autoGeneratedKeys", autoGeneratedKeys);
                fireEvent(event);
            }
            throw ex;
        } catch (RuntimeException ex) {
            {
                TraceErrorEvent event = new TraceErrorEvent("StatementExecuteUpdateError", new Date(startMillis), ex);
                event.putContext(TRACE_CONN_INFO, connection.getProperties().clone());
                event.putContext(TRACE_CONN_CONNECTED_TIME, connection.getConnectedTime());
                event.putContext(TRACE_CONN_ID, connection.getId());
                event.putContext(TRACE_STMT_ID, statement.getId());
                event.putContext(TRACE_STMT_SQL, sql);
                event.putContext("stmt.autoGeneratedKeys", autoGeneratedKeys);
                fireEvent(event);
            }
View Full Code Here


            return chain.statement_executeUpdate(statement, sql, columnIndexes);
        }

        long startMillis = System.currentTimeMillis();

        ConnectionProxy connection = statement.getConnectionProxy();
        {
            TraceEvent event = new TraceEvent("StatementExecuteUpdateBefore", new Date(startMillis));
            event.putContext(TRACE_CONN_INFO, connection.getProperties().clone());
            event.putContext(TRACE_CONN_CONNECTED_TIME, connection.getConnectedTime());
            event.putContext(TRACE_CONN_ID, connection.getId());
            event.putContext(TRACE_STMT_ID, statement.getId());
            event.putContext(TRACE_STMT_SQL, sql);
            event.putContext(TRACE_STMT_COLUMN_INDEXES, columnIndexes);

            fireEvent(event);
        }

        try {
            int updateCount = chain.statement_executeUpdate(statement, sql, columnIndexes);

            long timespan = System.currentTimeMillis() - startMillis;
            {
                TraceAfterEvent event = new TraceAfterEvent("StatementExecuteUpdateAfter", new Date(startMillis),
                                                            timespan);
                event.putContext(TRACE_CONN_INFO, connection.getProperties().clone());
                event.putContext(TRACE_CONN_CONNECTED_TIME, connection.getConnectedTime());
                event.putContext(TRACE_CONN_ID, connection.getId());
                event.putContext(TRACE_STMT_ID, statement.getId());
                event.putContext(TRACE_STMT_SQL, sql);
                event.putContext(TRACE_STMT_COLUMN_INDEXES, columnIndexes);
                event.putContext(TRACE_STMT_UPDATE_COUNT, updateCount);
                fireEvent(event);
            }

            return updateCount;
        } catch (SQLException ex) {
            {
                TraceErrorEvent event = new TraceErrorEvent("StatementExecuteUpdateError", new Date(startMillis), ex);
                event.putContext(TRACE_CONN_INFO, connection.getProperties().clone());
                event.putContext(TRACE_CONN_CONNECTED_TIME, connection.getConnectedTime());
                event.putContext(TRACE_CONN_ID, connection.getId());
                event.putContext(TRACE_STMT_ID, statement.getId());
                event.putContext(TRACE_STMT_SQL, sql);
                event.putContext(TRACE_STMT_COLUMN_INDEXES, columnIndexes);
                fireEvent(event);
            }
            throw ex;
        } catch (RuntimeException ex) {
            {
                TraceErrorEvent event = new TraceErrorEvent("StatementExecuteUpdateError", new Date(startMillis), ex);
                event.putContext(TRACE_CONN_INFO, connection.getProperties().clone());
                event.putContext(TRACE_CONN_CONNECTED_TIME, connection.getConnectedTime());
                event.putContext(TRACE_CONN_ID, connection.getId());
                event.putContext(TRACE_STMT_ID, statement.getId());
                event.putContext(TRACE_STMT_SQL, sql);
                event.putContext(TRACE_STMT_COLUMN_INDEXES, columnIndexes);
                fireEvent(event);
            }
View Full Code Here

            return chain.statement_executeUpdate(statement, sql, columnNames);
        }

        long startMillis = System.currentTimeMillis();

        ConnectionProxy connection = statement.getConnectionProxy();
        {
            TraceEvent event = new TraceEvent("StatementExecuteUpdateBefore", new Date(startMillis));
            event.putContext(TRACE_CONN_INFO, connection.getProperties().clone());
            event.putContext(TRACE_CONN_CONNECTED_TIME, connection.getConnectedTime());
            event.putContext(TRACE_CONN_ID, connection.getId());
            event.putContext(TRACE_STMT_ID, statement.getId());
            event.putContext(TRACE_STMT_SQL, sql);
            event.putContext(TRACE_STMT_COLUMN, columnNames);

            fireEvent(event);
        }

        try {
            int updateCount = chain.statement_executeUpdate(statement, sql, columnNames);

            long timespan = System.currentTimeMillis() - startMillis;
            {
                TraceAfterEvent event = new TraceAfterEvent("StatementExecuteUpdateAfter", new Date(startMillis),
                                                            timespan);
                event.putContext(TRACE_CONN_INFO, connection.getProperties().clone());
                event.putContext(TRACE_CONN_CONNECTED_TIME, connection.getConnectedTime());
                event.putContext(TRACE_CONN_ID, connection.getId());
                event.putContext(TRACE_STMT_ID, statement.getId());
                event.putContext(TRACE_STMT_SQL, sql);
                event.putContext(TRACE_STMT_COLUMN, columnNames);
                event.putContext(TRACE_STMT_UPDATE_COUNT, updateCount);
                fireEvent(event);
            }

            return updateCount;
        } catch (SQLException ex) {
            {
                TraceErrorEvent event = new TraceErrorEvent("StatementExecuteUpdateError", new Date(startMillis), ex);
                event.putContext(TRACE_CONN_INFO, connection.getProperties().clone());
                event.putContext(TRACE_CONN_CONNECTED_TIME, connection.getConnectedTime());
                event.putContext(TRACE_CONN_ID, connection.getId());
                event.putContext(TRACE_STMT_ID, statement.getId());
                event.putContext(TRACE_STMT_SQL, sql);
                event.putContext(TRACE_STMT_COLUMN, columnNames);
                fireEvent(event);
            }
            throw ex;
        } catch (RuntimeException ex) {
            {
                TraceErrorEvent event = new TraceErrorEvent("StatementExecuteUpdateError", new Date(startMillis), ex);
                event.putContext(TRACE_CONN_INFO, connection.getProperties().clone());
                event.putContext(TRACE_CONN_CONNECTED_TIME, connection.getConnectedTime());
                event.putContext(TRACE_CONN_ID, connection.getId());
                event.putContext(TRACE_STMT_ID, statement.getId());
                event.putContext(TRACE_STMT_SQL, sql);
                event.putContext(TRACE_STMT_COLUMN, columnNames);
                fireEvent(event);
            }
View Full Code Here

        }
        this.dataSourceStat = stat;
    }

    public ConnectionProxy connection_connect(FilterChain chain, Properties info) throws SQLException {
        ConnectionProxy connection = null;
        {
            long startNano = System.nanoTime();
            long startTime = System.currentTimeMillis();

            long nanoSpan;
            long nowTime = System.currentTimeMillis();

            connectStat.beforeConnect();
            dataSourceStat.getConnectionStat().beforeConnect();
            try {
                connection = super.connection_connect(chain, info);
                nanoSpan = System.nanoTime() - startNano;
            } catch (SQLException ex) {
                connectStat.connectError(ex);
                dataSourceStat.getConnectionStat().connectError(ex);
                throw ex;
            }
            connectStat.afterConnected(nanoSpan);
            dataSourceStat.getConnectionStat().afterConnected(nanoSpan);

            if (connection != null) {
                JdbcConnectionStat.Entry statEntry = getConnectionInfo(connection);

                dataSourceStat.getConnections().put(connection.getId(), statEntry);

                statEntry.setConnectTime(new Date(startTime));
                statEntry.setConnectTimespanNano(nanoSpan);
                statEntry.setEstablishNano(System.nanoTime());
                statEntry.setEstablishTime(nowTime);
View Full Code Here

        statementStat.beforeExecute();
        dataSourceStat.getStatementStat().beforeExecute();

        final JdbcStatementStat.Entry statementStat = getStatementInfo(statement);
        final ConnectionProxy connection = statement.getConnectionProxy();
        final JdbcConnectionStat.Entry connectionCounter = getConnectionInfo(connection);

        statementStat.setLastExecuteStartNano(System.nanoTime());
        statementStat.setLastExecuteSql(sql);
View Full Code Here

    @Override
    protected void statement_executeErrorAfter(StatementProxy statement, String sql, Throwable error) {

        JdbcStatementStat.Entry counter = getStatementInfo(statement);
        ConnectionProxy connection = statement.getConnectionProxy();
        JdbcConnectionStat.Entry connectionCounter = getConnectionInfo(connection);

        long nanoSpan = System.nanoTime() - counter.getLastExecuteStartNano();

        statementStat.error(error);
View Full Code Here

        chain.connection_setAutoCommit(connection, autoCommit);
    }

    public ConnectionProxy connection_connect(FilterChain chain, Properties info) throws SQLException {
        ConnectionProxy connection = null;
        {
            long startNano = System.nanoTime();
            long startTime = System.currentTimeMillis();

            long nanoSpan;
            long nowTime = System.currentTimeMillis();

            connectStat.beforeConnect();
            dataSourceStat.getConnectionStat().beforeConnect();
            try {
                connection = super.connection_connect(chain, info);
                nanoSpan = System.nanoTime() - startNano;
            } catch (SQLException ex) {
                connectStat.connectError(ex);
                dataSourceStat.getConnectionStat().connectError(ex);
                throw ex;
            }
            connectStat.afterConnected(nanoSpan);
            dataSourceStat.getConnectionStat().afterConnected(nanoSpan);

            if (connection != null) {
                JdbcConnectionStat.Entry statEntry = getConnectionInfo(connection);

                dataSourceStat.getConnections().put(connection.getId(), statEntry);

                statEntry.setConnectTime(new Date(startTime));
                statEntry.setConnectTimespanNano(nanoSpan);
                statEntry.setEstablishNano(System.nanoTime());
                statEntry.setEstablishTime(nowTime);
View Full Code Here

        statementStat.beforeExecute();
        dataSourceStat.getStatementStat().beforeExecute();

        final JdbcStatementStat.Entry statementStat = getStatementInfo(statement);
        final ConnectionProxy connection = statement.getConnectionProxy();
        final JdbcConnectionStat.Entry connectionCounter = getConnectionInfo(connection);

        statementStat.setLastExecuteStartNano(System.nanoTime());
        statementStat.setLastExecuteSql(sql);
View Full Code Here

    @Override
    protected void statement_executeErrorAfter(StatementProxy statement, String sql, Throwable error) {

        JdbcStatementStat.Entry counter = getStatementInfo(statement);
        ConnectionProxy connection = statement.getConnectionProxy();
        JdbcConnectionStat.Entry connectionCounter = getConnectionInfo(connection);

        long nanoSpan = System.nanoTime() - counter.getLastExecuteStartNano();

        statementStat.error(error);
View Full Code Here

            serverEncoding = druidEncodingFilterConfig.getServerEncoding();
        }
    }

    public ConnectionProxy connection_connect(FilterChain chain, Properties info) throws SQLException {
        ConnectionProxy conn = chain.connection_connect(info);

        CharsetParameter param = new CharsetParameter();
        param.setClientEncoding(info.getProperty(CharsetParameter.CLIENTENCODINGKEY));
        param.setServerEncoding(info.getProperty(CharsetParameter.SERVERENCODINGKEY));

        if (param.getClientEncoding() == null || "".equalsIgnoreCase(param.getClientEncoding())) {
            param.setClientEncoding(clientEncoding);
        }
        if (param.getServerEncoding() == null || "".equalsIgnoreCase(param.getServerEncoding())) {
            param.setServerEncoding(serverEncoding);
        }
        conn.getAttributes().put(ATTR_CHARSET_PARAMETER, param);
        conn.getAttributes().put(ATTR_CHARSET_CONVERTER,
                                 new CharsetConvert(param.getClientEncoding(), param.getServerEncoding()));

        return conn;
    }
View Full Code Here

TOP

Related Classes of com.alibaba.druid.proxy.jdbc.ConnectionProxy

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.