JdbcSyncSqlExecutor extends JdbcSqlExecutor implements SyncSqlExecutor { @Override @SneakyThrows public <T, R> R select(SqlRequest request, ResultWrapper<T, R> wrapper) { Connection connection = getConnection(request); try { return doSelect(connection, request, wrapper); } finally { releaseConnection(connection, request); } } JdbcSyncSqlExecutor(); abstract Connection getConnection(SqlRequest sqlRequest); abstract void releaseConnection(Connection connection, SqlRequest sqlRequest); @SneakyThrows void releaseStatement(Statement statement); @SneakyThrows void releaseResultSet(ResultSet resultSet); @Override @SneakyThrows int update(SqlRequest request); @Override @SneakyThrows void execute(SqlRequest request); @Override @SneakyThrows R select(SqlRequest request, ResultWrapper<T, R> wrapper);  }
@SneakyThrows @Test public void testSelectSingle() { Map<String, Object> data = executor.select(prepare("select 1 as data"), singleMap()); Assert.assertNotNull(data); Assert.assertEquals(data.get("DATA"), 1); }
@SneakyThrows @Test public void testSelectPrepare() { Map<String, Object> data = executor.select(prepare("select 1 as data where 1 = ?", 1), singleMap()); Assert.assertNotNull(data); Assert.assertEquals(data.get("DATA"), 1); }
@SneakyThrows @Test public void testSelectTemplate() { Map<String, Object> data = executor.select(template("select 1 as data where 1 = #{id}", Collections.singletonMap("id", 1)), singleMap()); Assert.assertNotNull(data); Assert.assertEquals(data.get("DATA"), 1); }