private void checkExecuteFetch( Connection conn, String sql, boolean isPrepare, int fetchCountMatch) throws SQLException { final Statement exeStatement; final ResultSet results; LoggingLocalJsonService.THREAD_LOG.get().enableAndClear(); if (isPrepare) { PreparedStatement statement = conn.prepareStatement(sql); exeStatement = statement; results = statement.executeQuery(); } else { Statement statement = conn.createStatement(); exeStatement = statement; results = statement.executeQuery(sql); } int count = 0; int fetchCount = 0; while (results.next()) { count++; } results.close(); exeStatement.close(); List<String[]> x = LoggingLocalJsonService.THREAD_LOG.get().getAndDisable(); for (String[] pair : x) { if (pair[0].contains("\"request\":\"fetch")) { fetchCount++; } } assertEquals(count, 196); assertEquals(fetchCount, fetchCountMatch); }
@Test public void testPrepareBindExecuteFetch() throws Exception { if (JDK17) { return; } LoggingLocalJsonService.THREAD_LOG.get().enableAndClear(); checkPrepareBindExecuteFetch(ljs()); List<String[]> x = LoggingLocalJsonService.THREAD_LOG.get().getAndDisable(); for (String[] pair : x) { System.out.println(pair[0] + "=" + pair[1]); } }