use of com.alibaba.druid.stat.JdbcSqlStat in project druid by alibaba.
the class StatFilterOpenInputStreamCountTest 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.getInputStreamOpenCount());
ResultSet rs = stmt.executeQuery();
rs.next();
rs.getBinaryStream(1);
rs.getBinaryStream(2);
rs.close();
stmt.close();
conn.close();
Assert.assertEquals(2, sqlStat.getInputStreamOpenCount());
sqlStat.reset();
Assert.assertEquals(0, sqlStat.getInputStreamOpenCount());
}
use of com.alibaba.druid.stat.JdbcSqlStat in project druid by alibaba.
the class StatFilterOpenInputStreamCountTest2 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.getInputStreamOpenCount());
ResultSet rs = stmt.executeQuery();
rs.next();
rs.getAsciiStream(1);
rs.getAsciiStream(2);
rs.close();
stmt.close();
conn.close();
Assert.assertEquals(2, sqlStat.getInputStreamOpenCount());
sqlStat.reset();
Assert.assertEquals(0, sqlStat.getInputStreamOpenCount());
}
use of com.alibaba.druid.stat.JdbcSqlStat in project druid by alibaba.
the class StatFilterReadBytesLengthTest 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.getReadStringLength());
Assert.assertEquals(0, sqlStat.getReadBytesLength());
ResultSet rs = stmt.executeQuery();
rs.next();
rs.getBytes("1");
rs.close();
stmt.close();
conn.close();
Assert.assertEquals(0, sqlStat.getReadStringLength());
Assert.assertEquals(7, sqlStat.getReadBytesLength());
sqlStat.reset();
Assert.assertEquals(0, sqlStat.getReadStringLength());
Assert.assertEquals(0, sqlStat.getReadBytesLength());
}
use of com.alibaba.druid.stat.JdbcSqlStat in project druid by alibaba.
the class StatFilterReadBytesLengthTest 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.getReadStringLength());
Assert.assertEquals(0, sqlStat.getReadBytesLength());
ResultSet rs = stmt.executeQuery();
rs.next();
rs.getBytes(1);
rs.close();
stmt.close();
conn.close();
Assert.assertEquals(0, sqlStat.getReadStringLength());
Assert.assertEquals(6, sqlStat.getReadBytesLength());
sqlStat.reset();
Assert.assertEquals(0, sqlStat.getReadStringLength());
Assert.assertEquals(0, sqlStat.getReadBytesLength());
}
use of com.alibaba.druid.stat.JdbcSqlStat in project druid by alibaba.
the class StatFilterReadStringLengthTest 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.getReadStringLength());
ResultSet rs = stmt.executeQuery();
rs.next();
rs.getString(1);
rs.close();
stmt.close();
conn.close();
Assert.assertEquals(6, sqlStat.getReadStringLength());
sqlStat.reset();
Assert.assertEquals(0, sqlStat.getReadStringLength());
}
Aggregations