use of com.alibaba.druid.stat.JdbcSqlStat in project druid by alibaba.
the class SqlStatisticTest method test_sql_stat.
public void test_sql_stat() throws Exception {
JdbcSqlStat stat = new JdbcSqlStat("SELECT * FROM t_user");
Assert.assertEquals(null, stat.getExecuteLastStartTime());
Assert.assertEquals(null, stat.getExecuteNanoSpanMaxOccurTime());
Assert.assertEquals(null, stat.getExecuteErrorLastTime());
stat.error(new Exception());
Assert.assertNotNull(stat.getExecuteErrorLast());
Assert.assertNotNull(stat.getExecuteErrorLastTime());
}
use of com.alibaba.druid.stat.JdbcSqlStat in project druid by alibaba.
the class StatFilter method clobOpenAfter.
private void clobOpenAfter(JdbcDataSourceStat dataSourceStat, StatementProxy stmt, ClobProxy clob) {
dataSourceStat.incrementClobOpenCount();
if (stmt != null) {
JdbcSqlStat sqlStat = stmt.getSqlStat();
if (sqlStat != null) {
sqlStat.incrementClobOpenCount();
}
}
StatFilterContext.getInstance().clob_open();
}
use of com.alibaba.druid.stat.JdbcSqlStat in project druid by alibaba.
the class StatFilter method statementExecuteBatchBefore.
@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.isRemoved()) {
sqlStat = createSqlStat(statement, sql);
statement.setSqlStat(sqlStat);
}
if (sqlStat != null) {
sqlStat.addExecuteBatchCount(batchSize);
}
internalBeforeStatementExecute(statement, sql);
}
use of com.alibaba.druid.stat.JdbcSqlStat in project druid by alibaba.
the class StatFilter method statement_executeErrorAfter.
@Override
protected void statement_executeErrorAfter(StatementProxy statement, String sql, Throwable error) {
ConnectionProxy connection = statement.getConnectionProxy();
JdbcConnectionStat.Entry connectionCounter = getConnectionInfo(connection);
long nanos = System.nanoTime() - statement.getLastExecuteStartNano();
JdbcDataSourceStat dataSourceStat = statement.getConnectionProxy().getDirectDataSource().getDataSourceStat();
dataSourceStat.getStatementStat().error(error);
dataSourceStat.getStatementStat().afterExecute(nanos);
connectionCounter.error(error);
// SQL
JdbcSqlStat sqlStat = statement.getSqlStat();
if (sqlStat != null) {
sqlStat.decrementExecutingCount();
sqlStat.error(error);
sqlStat.addExecuteTime(statement.getLastExecuteType(), statement.isFirstResultSet(), nanos);
statement.setLastExecuteTimeNano(nanos);
}
StatFilterContext.getInstance().executeAfter(sql, nanos, error);
Profiler.release(nanos);
}
use of com.alibaba.druid.stat.JdbcSqlStat in project druid by alibaba.
the class StatFilter method statementPrepareCallAfter.
@Override
public void statementPrepareCallAfter(CallableStatementProxy statement) {
JdbcDataSourceStat dataSourceStat = statement.getConnectionProxy().getDirectDataSource().getDataSourceStat();
dataSourceStat.getStatementStat().incrementPrepareCallCount();
JdbcSqlStat sqlStat = createSqlStat(statement, statement.getSql());
statement.setSqlStat(sqlStat);
}
Aggregations