### Question:
JDBCDriver extends AbstractLensDriver { @Override public LensResultSet execute(QueryContext context) throws LensException { checkConfigured(); String rewrittenQuery = rewriteQuery(context); log.info("{} Execute {}", getFullyQualifiedName(), context.getQueryHandle()); QueryResult result = executeInternal(context, rewrittenQuery); return result.getLensResultSet(true); }  @Override void configure(Configuration conf, String driverType, String driverName); void init(); QueryCost calculateQueryCost(AbstractQueryContext qctx); @Override QueryCost estimate(AbstractQueryContext qctx); @Override DriverQueryPlan explain(AbstractQueryContext explainCtx); void validate(AbstractQueryContext pContext); @Override void prepare(PreparedQueryContext pContext); @Override DriverQueryPlan explainAndPrepare(PreparedQueryContext pContext); @Override void closePreparedQuery(QueryPrepareHandle handle); @Override LensResultSet execute(QueryContext context); @Override void executeAsync(QueryContext context); @Override void updateStatus(QueryContext context); @Override void closeResultSet(QueryHandle handle); @Override boolean cancelQuery(QueryHandle handle); @Override void closeQuery(QueryHandle handle); @Override void close(); @Override void registerDriverEventListener(LensEventListener<DriverEvent> driverEventListener); @Override void readExternal(ObjectInput arg0); @Override void writeExternal(ObjectOutput arg0); @Override StatusUpdateMethod getStatusUpdateMethod(); static final AtomicInteger THID; }### Answer:
@Test public void testExecute() throws Exception { createTable("execute_test"); insertData("execute_test"); final String query = "SELECT * FROM execute_test"; QueryContext context = createQueryContext(query); LensResultSet resultSet = driver.execute(context); assertNotNull(resultSet); if (resultSet instanceof InMemoryResultSet) { InMemoryResultSet rs = (InMemoryResultSet) resultSet; LensResultSetMetadata rsMeta = rs.getMetadata(); assertEquals(rsMeta.getColumns().size(), 1); ColumnDescriptor col1 = rsMeta.getColumns().get(0); assertEquals(col1.getTypeName().toLowerCase(), "int"); assertEquals(col1.getName(), "ID"); while (rs.hasNext()) { ResultRow row = rs.next(); List<Object> rowObjects = row.getValues(); } if (rs instanceof JDBCResultSet) { ((JDBCResultSet) rs).close(); } } }
@Test public void testConnectionCloseForSuccessfulQueries() throws Exception { createTable("valid_conn_close"); insertData("valid_conn_close"); final String query = "SELECT * from valid_conn_close"; QueryContext ctx = createQueryContext(query); for (int i = 0; i < ConnectionPoolProperties.JDBC_POOL_MAX_SIZE.getDefaultValue(); i++) { LensResultSet resultSet = driver.execute(ctx); assertNotNull(resultSet); if (resultSet instanceof InMemoryResultSet) { InMemoryResultSet rs = (InMemoryResultSet) resultSet; LensResultSetMetadata rsMeta = rs.getMetadata(); assertEquals(rsMeta.getColumns().size(), 1); ColumnDescriptor col1 = rsMeta.getColumns().get(0); assertEquals(col1.getTypeName().toLowerCase(), "int"); assertEquals(col1.getName(), "ID"); while (rs.hasNext()) { ResultRow row = rs.next(); List<Object> rowObjects = row.getValues(); } } System.out.println("@@@@ QUERY " + (i + 1)); } String validQuery = "SELECT * FROM valid_conn_close"; QueryContext validCtx = createQueryContext(validQuery); System.out.println("@@@ Submitting query after pool quota used"); driver.execute(validCtx); }