Package com.alibaba.druid.proxy.jdbc

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


            return chain.preparedStatement_executeUpdate(statement);
        }

        long startMillis = System.currentTimeMillis();

        ConnectionProxy connection = statement.getConnectionProxy();
        {
            TraceEvent event = new TraceEvent("PreparedStatementExecuteUpdateBefore", 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, statement.getSql());
            event.putContext(TRACE_STMT_PARAMS, getParameters(statement));

            fireEvent(event);
        }

        try {
            int updateCount = chain.preparedStatement_executeUpdate(statement);

            long timespan = System.currentTimeMillis() - startMillis;
            {
                TraceAfterEvent event = new TraceAfterEvent("PreparedStatementExecuteQueryAfter",
                                                            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, statement.getSql());
                event.putContext(TRACE_STMT_PARAMS, getParameters(statement));
                event.putContext(TRACE_STMT_UPDATE_COUNT, updateCount);
                fireEvent(event);
            }

            return updateCount;
        } catch (SQLException ex) {
            {
                TraceErrorEvent event = new TraceErrorEvent("PreparedStatementExecuteUpdateError",
                                                            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, statement.getSql());
                event.putContext(TRACE_STMT_PARAMS, getParameters(statement));
                fireEvent(event);
            }
            throw ex;
        } catch (RuntimeException ex) {
            {
                TraceErrorEvent event = new TraceErrorEvent("PreparedStatementExecuteUpdateError",
                                                            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, statement.getSql());
                event.putContext(TRACE_STMT_PARAMS, getParameters(statement));
                fireEvent(event);
            }
View Full Code Here


            return;
        }

        long startMillis = System.currentTimeMillis();

        ConnectionProxy connection = statement.getConnectionProxy();
        {
            TraceEvent event = new TraceEvent("PreparedStatementClearParametersBefore", 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_PARAMS, getParameters(statement));
            event.putContext(TRACE_STMT_SQL, statement.getSql());

            fireEvent(event);
        }

        try {
            chain.preparedStatement_clearParameters(statement);

            long timespan = System.currentTimeMillis() - startMillis;
            {
                TraceAfterEvent event = new TraceAfterEvent("PreparedStatementClearParametersAfter",
                                                            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, statement.getSql());
                event.putContext(TRACE_STMT_PARAMS, getParameters(statement));
                fireEvent(event);
            }
        } catch (SQLException ex) {
            {
                TraceErrorEvent event = new TraceErrorEvent("PreparedStatementClearParametersError",
                                                            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, statement.getSql());
                event.putContext(TRACE_STMT_PARAMS, getParameters(statement));
                fireEvent(event);
            }
            throw ex;
        } catch (RuntimeException ex) {
            {
                TraceErrorEvent event = new TraceErrorEvent("PreparedStatementClearParametersError",
                                                            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, statement.getSql());
                event.putContext(TRACE_STMT_PARAMS, getParameters(statement));
                fireEvent(event);
            }
View Full Code Here

            return;
        }

        long startMillis = System.currentTimeMillis();

        ConnectionProxy connection = statement.getConnectionProxy();
        {
            TraceEvent event = new TraceEvent("PreparedStatementAddBatchBefore", 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, statement.getSql());
            event.putContext(TRACE_STMT_PARAMS, getParameters(statement));

            fireEvent(event);
        }

        try {
            chain.preparedStatement_addBatch(statement);

            long timespan = System.currentTimeMillis() - startMillis;
            {
                TraceAfterEvent event = new TraceAfterEvent("PreparedStatementAddBatchAfter", 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, statement.getSql());
                event.putContext(TRACE_STMT_PARAMS, getParameters(statement));
                fireEvent(event);
            }
        } catch (SQLException ex) {
            {
                TraceErrorEvent event = new TraceErrorEvent("PreparedStatementAddBatchError", 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, statement.getSql());
                event.putContext(TRACE_STMT_PARAMS, getParameters(statement));
                fireEvent(event);
            }
            throw ex;
        } catch (RuntimeException ex) {
            {
                TraceErrorEvent event = new TraceErrorEvent("PreparedStatementAddBatchError", 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, statement.getSql());
                event.putContext(TRACE_STMT_PARAMS, getParameters(statement));
                fireEvent(event);
            }
View Full Code Here

        }

        boolean hasMore = chain.resultSet_next(resultSet);

        StatementProxy statement = resultSet.getStatementProxy();
        ConnectionProxy connection = statement.getConnectionProxy();

        {
            TraceEvent event = new TraceEvent("ResultSetNext", new Date());
            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_SQL, resultSet.getSql());
            event.putContext(TRACE_STMT_ID, statement.getId());
            event.putContext(TRACE_RS_ID, resultSet.getId());
            event.putContext("rs.hasMore", hasMore);
View Full Code Here

        }

        boolean hasMore = chain.resultSet_previous(resultSet);

        StatementProxy statement = resultSet.getStatementProxy();
        ConnectionProxy connection = statement.getConnectionProxy();

        {
            TraceEvent event = new TraceEvent("ResultSetPrevious", new Date());
            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_SQL, resultSet.getSql());
            event.putContext(TRACE_STMT_ID, statement.getId());
            event.putContext(TRACE_RS_ID, resultSet.getId());
            event.putContext("rs.hasMore", hasMore);
View Full Code Here

        }

        chain.resultSet_close(resultSet);

        StatementProxy statement = resultSet.getStatementProxy();
        ConnectionProxy connection = statement.getConnectionProxy();

        {
            TraceEvent event = new TraceEvent("ResultSetCloseAfter", new Date());
            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_SQL, resultSet.getSql());
            event.putContext(TRACE_STMT_ID, statement.getId());
            event.putContext(TRACE_RS_ID, resultSet.getId());

            event.putContext(TRACE_RS_CURSOR_INDEX, resultSet.getCursorIndex());
View Full Code Here

        }

        resultSet.setConstructNano();

        StatementProxy statement = resultSet.getStatementProxy();
        ConnectionProxy connection = statement.getConnectionProxy();

        TraceEvent event = new TraceEvent("ResultSetPrevious", new Date());
        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_SQL, resultSet.getSql());
        event.putContext(TRACE_STMT_ID, statement.getId());
        event.putContext(TRACE_RS_ID, resultSet.getId());

        List<Map<String, Object>> columns = new ArrayList<Map<String, Object>>();
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

            return chain.statement_executeQuery(statement, sql);
        }

        long startMillis = System.currentTimeMillis();

        ConnectionProxy connection = statement.getConnectionProxy();
        {
            TraceEvent event = new TraceEvent("StatementExecuteQueryBefore", 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);

            fireEvent(event);
        }

        try {
            ResultSetProxy resultSet = chain.statement_executeQuery(statement, sql);

            long timespan = System.currentTimeMillis() - startMillis;
            {
                TraceAfterEvent event = new TraceAfterEvent("StatementExecuteQueryAfter", 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_RS_ID, resultSet.getId());
                fireEvent(event);
            }

            resultSetOpenAfter(resultSet);

            return resultSet;
        } catch (SQLException ex) {
            {
                TraceErrorEvent event = new TraceErrorEvent("StatementExecuteQueryError", 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);
                fireEvent(event);
            }
            throw ex;
        } catch (RuntimeException ex) {
            {
                TraceErrorEvent event = new TraceErrorEvent("StatementExecuteQueryError", 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);
                fireEvent(event);
            }
            throw ex;
View Full Code Here

            return chain.statement_executeUpdate(statement, sql);
        }

        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);

            fireEvent(event);
        }

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

            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_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);
                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);
                fireEvent(event);
            }
            throw ex;
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.