org.apache.tomcat.jdbc.pool.interceptor.SlowQueryReport Java Examples
The following examples show how to use
org.apache.tomcat.jdbc.pool.interceptor.SlowQueryReport.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TestSlowQueryReport.java From Tomcat8-Source-Read with MIT License | 6 votes |
@Test public void testFastSql() throws Exception { int count = 3; Connection con = this.datasource.getConnection(); String fastSql = this.datasource.getValidationQuery(); for (int i=0; i<count; i++) { Statement st = con.createStatement(); ResultSet rs = st.executeQuery(fastSql); rs.close(); st.close(); } Map<String,SlowQueryReport.QueryStats> map = SlowQueryReport.getPoolStats(datasource.getPool().getName()); Assert.assertNotNull(map); Assert.assertEquals(1,map.size()); ConnectionPool pool = datasource.getPool(); con.close(); tearDown(); Assert.assertNull(SlowQueryReport.getPoolStats(pool.getName())); }
Example #2
Source File: TestSlowQueryReport.java From Tomcat8-Source-Read with MIT License | 6 votes |
@Test public void testFailedSql() throws Exception { int count = 3; Connection con = this.datasource.getConnection(); for (int i=0; i<count; i++) { Statement st = con.createStatement(); try { ResultSet rs = st.executeQuery(failedSql); rs.close(); }catch (Exception x) { // NO-OP } st.close(); } Map<String,SlowQueryReport.QueryStats> map = SlowQueryReport.getPoolStats(datasource.getPool().getName()); Assert.assertNotNull(map); Assert.assertEquals(1,map.size()); ConnectionPool pool = datasource.getPool(); String key = map.keySet().iterator().next(); SlowQueryReport.QueryStats stats = map.get(key); System.out.println("Stats:"+stats); con.close(); tearDown(); Assert.assertNull(SlowQueryReport.getPoolStats(pool.getName())); }
Example #3
Source File: TestSlowQueryReport.java From Tomcat7.0.67 with Apache License 2.0 | 6 votes |
@Test public void testFastSql() throws Exception { int count = 3; this.init(); this.datasource.setMaxActive(1); this.datasource.setJdbcInterceptors(SlowQueryReport.class.getName()); Connection con = this.datasource.getConnection(); String fastSql = this.datasource.getValidationQuery(); for (int i=0; i<count; i++) { Statement st = con.createStatement(); ResultSet rs = st.executeQuery(fastSql); rs.close(); st.close(); } Map<String,SlowQueryReport.QueryStats> map = SlowQueryReport.getPoolStats(datasource.getPool().getName()); Assert.assertNotNull(map); Assert.assertEquals(0,map.size()); ConnectionPool pool = datasource.getPool(); con.close(); tearDown(); Assert.assertNull(SlowQueryReport.getPoolStats(pool.getName())); }
Example #4
Source File: TestSlowQueryReport.java From tomcatsrc with Apache License 2.0 | 6 votes |
@Test public void testFastSql() throws Exception { int count = 3; this.init(); this.datasource.setMaxActive(1); this.datasource.setJdbcInterceptors(SlowQueryReport.class.getName()); Connection con = this.datasource.getConnection(); String fastSql = this.datasource.getValidationQuery(); for (int i=0; i<count; i++) { Statement st = con.createStatement(); ResultSet rs = st.executeQuery(fastSql); rs.close(); st.close(); } Map<String,SlowQueryReport.QueryStats> map = SlowQueryReport.getPoolStats(datasource.getPool().getName()); Assert.assertNotNull(map); Assert.assertEquals(0,map.size()); ConnectionPool pool = datasource.getPool(); con.close(); tearDown(); Assert.assertNull(SlowQueryReport.getPoolStats(pool.getName())); }
Example #5
Source File: TestSlowQueryReport.java From Tomcat7.0.67 with Apache License 2.0 | 5 votes |
@Test public void testFailedSql() throws Exception { int count = 3; this.init(); this.datasource.setMaxActive(1); this.datasource.setJdbcInterceptors(SlowQueryReport.class.getName()); Connection con = this.datasource.getConnection(); String slowSql = "select 1 from non_existent"; for (int i=0; i<count; i++) { Statement st = con.createStatement(); try { ResultSet rs = st.executeQuery(slowSql); rs.close(); }catch (Exception x) { // NO-OP } st.close(); } Map<String,SlowQueryReport.QueryStats> map = SlowQueryReport.getPoolStats(datasource.getPool().getName()); Assert.assertNotNull(map); Assert.assertEquals(1,map.size()); ConnectionPool pool = datasource.getPool(); String key = map.keySet().iterator().next(); SlowQueryReport.QueryStats stats = map.get(key); System.out.println("Stats:"+stats); con.close(); tearDown(); Assert.assertNull(SlowQueryReport.getPoolStats(pool.getName())); }
Example #6
Source File: TestSlowQueryReport.java From tomcatsrc with Apache License 2.0 | 5 votes |
@Test public void testFailedSql() throws Exception { int count = 3; this.init(); this.datasource.setMaxActive(1); this.datasource.setJdbcInterceptors(SlowQueryReport.class.getName()); Connection con = this.datasource.getConnection(); String slowSql = "select 1 from non_existent"; for (int i=0; i<count; i++) { Statement st = con.createStatement(); try { ResultSet rs = st.executeQuery(slowSql); rs.close(); }catch (Exception x) { // NO-OP } st.close(); } Map<String,SlowQueryReport.QueryStats> map = SlowQueryReport.getPoolStats(datasource.getPool().getName()); Assert.assertNotNull(map); Assert.assertEquals(1,map.size()); ConnectionPool pool = datasource.getPool(); String key = map.keySet().iterator().next(); SlowQueryReport.QueryStats stats = map.get(key); System.out.println("Stats:"+stats); con.close(); tearDown(); Assert.assertNull(SlowQueryReport.getPoolStats(pool.getName())); }