use of com.alibaba.druid.stat.JdbcSqlStat in project druid by alibaba.
the class StatFilterExecuteFirstResultSetTest method test_stat.
public void test_stat() throws Exception {
Assert.assertTrue(dataSource.isInited());
final String sql = "select 1";
Connection conn = dataSource.getConnection();
PreparedStatement stmt = conn.prepareStatement(sql);
boolean firstResult = stmt.execute();
Assert.assertTrue(firstResult);
ResultSet rs = stmt.getResultSet();
rs.next();
rs.close();
stmt.close();
conn.close();
JdbcSqlStat sqlStat = dataSource.getDataSourceStat().getSqlStat(sql);
Assert.assertEquals(1, sqlStat.getHistogramSum());
Assert.assertEquals(1, sqlStat.getExecuteAndResultHoldTimeHistogramSum());
}
use of com.alibaba.druid.stat.JdbcSqlStat in project druid by alibaba.
the class StatFilterOpenBlobCountTest method test_stat_1.
public void test_stat_1() throws Exception {
Connection conn = dataSource.getConnection();
String sql = "select 'x'";
PreparedStatement stmt = conn.prepareStatement("select 'x'");
JdbcSqlStat sqlStat = dataSource.getDataSourceStat().getSqlStat(sql);
Assert.assertEquals(0, sqlStat.getBlobOpenCount());
ResultSet rs = stmt.executeQuery();
rs.next();
rs.getBlob("1");
rs.getBlob("2");
rs.getBlob("3");
rs.close();
stmt.close();
conn.close();
Assert.assertEquals(3, sqlStat.getBlobOpenCount());
sqlStat.reset();
Assert.assertEquals(0, sqlStat.getBlobOpenCount());
}
use of com.alibaba.druid.stat.JdbcSqlStat in project druid by alibaba.
the class StatFilterOpenBlobCountTest method test_stat.
public void test_stat() throws Exception {
Connection conn = dataSource.getConnection();
String sql = "select 'x'";
PreparedStatement stmt = conn.prepareStatement("select 'x'");
JdbcSqlStat sqlStat = dataSource.getDataSourceStat().getSqlStat(sql);
Assert.assertEquals(0, sqlStat.getBlobOpenCount());
ResultSet rs = stmt.executeQuery();
rs.next();
rs.getBlob(1);
rs.getBlob(2);
rs.close();
stmt.close();
conn.close();
Assert.assertEquals(2, sqlStat.getBlobOpenCount());
sqlStat.reset();
Assert.assertEquals(0, sqlStat.getBlobOpenCount());
}
use of com.alibaba.druid.stat.JdbcSqlStat in project druid by alibaba.
the class StatFilterOpenBlobCountTest2 method test_stat_2.
public void test_stat_2() throws Exception {
Connection conn = dataSource.getConnection();
String sql = "select 'x'";
PreparedStatement stmt = conn.prepareStatement("select 'x'");
JdbcSqlStat sqlStat = dataSource.getDataSourceStat().getSqlStat(sql);
Assert.assertEquals(0, sqlStat.getBlobOpenCount());
ResultSet rs = stmt.executeQuery();
rs.next();
rs.getObject(1, Collections.<String, Class<?>>emptyMap());
rs.getObject(2, Collections.<String, Class<?>>emptyMap());
rs.getObject(3, Collections.<String, Class<?>>emptyMap());
rs.getObject(4, Collections.<String, Class<?>>emptyMap());
rs.close();
stmt.close();
conn.close();
Assert.assertEquals(4, sqlStat.getBlobOpenCount());
sqlStat.reset();
Assert.assertEquals(0, sqlStat.getBlobOpenCount());
}
use of com.alibaba.druid.stat.JdbcSqlStat in project druid by alibaba.
the class StatFilterOpenBlobCountTest2 method test_stat_4.
public void test_stat_4() throws Exception {
Connection conn = dataSource.getConnection();
String sql = "select 'x'";
PreparedStatement stmt = conn.prepareStatement("select 'x'");
JdbcSqlStat sqlStat = dataSource.getDataSourceStat().getSqlStat(sql);
Assert.assertEquals(0, sqlStat.getBlobOpenCount());
ResultSet rs = stmt.executeQuery();
rs.next();
rs.getObject("1", Collections.<String, Class<?>>emptyMap());
rs.getObject("2", Collections.<String, Class<?>>emptyMap());
rs.getObject("3", Collections.<String, Class<?>>emptyMap());
rs.getObject("4", Collections.<String, Class<?>>emptyMap());
rs.getObject("5", Collections.<String, Class<?>>emptyMap());
rs.close();
stmt.close();
conn.close();
Assert.assertEquals(5, sqlStat.getBlobOpenCount());
sqlStat.reset();
Assert.assertEquals(0, sqlStat.getBlobOpenCount());
}
Aggregations