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.getInputStreamOpenCount()); ResultSet rs = stmt.executeQuery(); rs.next(); rs.getAsciiStream("1"); rs.getAsciiStream("2"); rs.getAsciiStream("3"); rs.close(); stmt.close(); conn.close(); Assert.assertEquals(3, sqlStat.getInputStreamOpenCount()); sqlStat.reset(); Assert.assertEquals(0, sqlStat.getInputStreamOpenCount()); }
public void test_merge() throws Exception { for (int i = 1000; i < 2000; ++i) { String tableName = "t" + i; String sql = "select * from " + tableName + " where " + tableName + ".id = " + i; Connection conn = dataSource.getConnection(); Statement stmt = conn.createStatement(); stmt.execute(sql); stmt.close(); conn.close(); } Assert.assertEquals(1, dataSource.getDataSourceStat().getSqlStatMap().size()); }