Examples of JdbcSqlStat


Examples of com.alibaba.druid.stat.JdbcSqlStat

    @Override
    public void statementPrepareCallAfter(CallableStatementProxy statement) {
        dataSourceStat.getStatementStat().incrementPrepareCallCount();

        JdbcSqlStat sqlStat = createSqlStat(statement, statement.getSql());
        statement.setSqlStat(sqlStat);
    }
View Full Code Here

Examples of com.alibaba.druid.stat.JdbcSqlStat

    }

    @Override
    public void statementPrepareAfter(PreparedStatementProxy statement) {
        dataSourceStat.getStatementStat().incrementPrepareCounter();
        JdbcSqlStat sqlStat = createSqlStat(statement, statement.getSql());
        statement.setSqlStat(sqlStat);
    }
View Full Code Here

Examples of com.alibaba.druid.stat.JdbcSqlStat

    @Override
    protected void statementExecuteBatchBefore(StatementProxy statement) {
        final String sql = statement.getBatchSql();

        final int batchSize = statement.getBatchSqlList().size();
        JdbcSqlStat sqlStat = statement.getSqlStat();
        if (sqlStat == null) {
            sqlStat = createSqlStat(statement, sql);
            statement.setSqlStat(sqlStat);
        }

        if (sqlStat != null) {
            sqlStat.addExecuteBatchCount(batchSize);
        }

        internalBeforeStatementExecute(statement, sql);

    }
View Full Code Here

Examples of com.alibaba.druid.stat.JdbcSqlStat

            connectionCounter.setLastStatementStatckTrace(new Exception());
        }

        // //////////SQL

        JdbcSqlStat sqlStat = statement.getSqlStat();
        if (sqlStat == null) {
            sqlStat = createSqlStat(statement, sql);
            statement.setSqlStat(sqlStat);
        }

        JdbcStatContext statContext = JdbcStatManager.getInstance().getStatContext();
        if (statContext != null) {
            sqlStat.setName(statContext.getName());
            sqlStat.setFile(statContext.getFile());
        }

        if (sqlStat != null) {
            sqlStat.setExecuteLastStartTime(System.currentTimeMillis());
            sqlStat.incrementRunningCount();

            try {
                boolean inTransaction = !statement.getConnectionProxy().getAutoCommit();
                if (inTransaction) {
                    sqlStat.incrementInTransactionCount();
                }
            } catch (SQLException e) {
                LOG.error("getAutoCommit error", e);
            }
        }
View Full Code Here

Examples of com.alibaba.druid.stat.JdbcSqlStat

        long nanoSpan = nowNano - entry.getLastExecuteStartNano();

        dataSourceStat.getStatementStat().afterExecute(nanoSpan);

        // // SQL
        final JdbcSqlStat sqlStat = statement.getSqlStat();

        if (sqlStat != null) {
            sqlStat.incrementExecuteSuccessCount();
            for (int updateCount : updateCountArray) {
                sqlStat.addUpdateCount(updateCount);
            }

            sqlStat.decrementRunningCount();
            sqlStat.addExecuteTime(statement.getLastExecuteType(), nanoSpan);
            statement.setLastExecuteTimeNano(nanoSpan);
            if ((!statement.isFirstResultSet()) && statement.getLastExecuteType() == StatementExecuteType.Execute) {
              try {
          int updateCount = statement.getUpdateCount();
          sqlStat.addUpdateCount(updateCount);
        } catch (SQLException e) {
          LOG.error("getUpdateCount error", e);
        }
            }

            long millis = nanoSpan / (1000 * 1000);
            if (millis >= slowSqlMillis) {
                StringBuilder buf = new StringBuilder();
                buf.append('[');
                int index = 0;
                for (JdbcParameter parameter : statement.getParameters().values()) {
                    if (index != 0) {
                        buf.append(',');
                    }
                    Object value = parameter.getValue();
                    if (value == null) {
                        buf.append("null");
                    } else if (value instanceof String) {
                        buf.append('"');
                        String text = (String) value;
                        if (text.length() > 100) {
                            for (int i = 0; i < 97; ++i) {
                                char ch = text.charAt(i);
                                if (ch == '\'') {
                                    buf.append('\\');
                                    buf.append(ch);
                                } else {
                                    buf.append(ch);
                                }
                            }
                            buf.append("...");
                        } else {
                            for (int i = 0; i < text.length(); ++i) {
                                char ch = text.charAt(i);
                                if (ch == '\'') {
                                    buf.append('\\');
                                    buf.append(ch);
                                } else {
                                    buf.append(ch);
                                }
                            }
                        }
                        buf.append('"');
                    } else if (value instanceof Number) {
                        buf.append(value.toString());
                    } else if (value instanceof java.util.Date) {
                        java.util.Date date = (java.util.Date) value;
                        buf.append(date.getClass().getSimpleName());
                        buf.append('(');
                        buf.append(date.getTime());
                        buf.append(')');
                    } else if (value instanceof Boolean) {
                        buf.append(value.toString());
                    } else if (value instanceof InputStream) {
                        buf.append("<InputStream>");
                    } else if (value instanceof Clob) {
                        buf.append("<Clob>");
                    } else if (value instanceof NClob) {
                        buf.append("<NClob>");
                    } else if (value instanceof Blob) {
                        buf.append("<Blob>");
                    } else {
                        buf.append('<');
                        buf.append(value.getClass().getName());
                        buf.append('>');
                    }
                    index++;
                }
                buf.append(']');
                sqlStat.setLastSlowParameters(buf.toString());
            }
        }
    }
View Full Code Here

Examples of com.alibaba.druid.stat.JdbcSqlStat

        dataSourceStat.getStatementStat().afterExecute(nanoSpan);

        connectionCounter.error(error);

        // SQL
        JdbcSqlStat sqlStat = statement.getSqlStat();

        if (sqlStat != null) {
            sqlStat.error(error);
            sqlStat.addExecuteTime(statement.getLastExecuteType(), nanoSpan);
            statement.setLastExecuteTimeNano(nanoSpan);
        }

        super.statement_executeErrorAfter(statement, sql, error);
    }
View Full Code Here

Examples of com.alibaba.druid.stat.JdbcSqlStat

        dataSourceStat.getResultSetStat().incrementCloseCounter();

        String sql = resultSet.getSql();
        if (sql != null) {
            JdbcSqlStat sqlStat = resultSet.getSqlStat();
            if (sqlStat != null) {
                sqlStat.addFetchRowCount(fetchCount);
                long stmtExecuteNano = resultSet.getStatementProxy().getLastExecuteTimeNano();
                sqlStat.addResultSetHoldTimeNano(stmtExecuteNano, nanoSpan);
            }
        }

        chain.resultSet_close(resultSet);
    }
View Full Code Here

Examples of com.alibaba.druid.stat.JdbcSqlStat

    @Override
    public void statementPrepareCallAfter(CallableStatementProxy statement) {
        statementStat.incrementPrepareCallCount();
        dataSourceStat.getStatementStat().incrementPrepareCallCount();

        JdbcSqlStat sqlStat = createSqlStat(statement, statement.getSql());
        statement.getAttributes().put(ATTR_SQL, sqlStat);
        ;

        // super.statementPrepareCallAfter(statement);
    }
View Full Code Here

Examples of com.alibaba.druid.stat.JdbcSqlStat

    @Override
    public void statementPrepareAfter(PreparedStatementProxy statement) {
        statementStat.incrementPrepareCounter();
        dataSourceStat.getStatementStat().incrementPrepareCounter();
        JdbcSqlStat sqlStat = createSqlStat(statement, statement.getSql());
        statement.getAttributes().put(ATTR_SQL, sqlStat);

        // super.statementPrepareAfter(statement);
    }
View Full Code Here

Examples of com.alibaba.druid.stat.JdbcSqlStat

    @Override
    protected void statementExecuteBatchBefore(StatementProxy statement) {
        final String sql = statement.getBatchSql();

        final int batchSize = statement.getBatchSqlList().size();
        JdbcSqlStat sqlStat = getSqlStat(statement);
        if (sqlStat == null) {
            sqlStat = createSqlStat(statement, sql);
            statement.getAttributes().put(ATTR_SQL, sqlStat);
        }

        sqlStat.addExecuteBatchCount(batchSize);

        internalBeforeStatementExecute(statement, sql);

        // super.statementExecuteBatchBefore(statement);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.