# jdbcclient Companion code for **JdbcClient in Spring Framework 7: Modern JDBC Without JPA (vs JdbcTemplate)** on [ankurm.com](https://ankurm.com). One `product` table on in-memory H2, a `JdbcClient` repository next to the same four operations written with `JdbcTemplate`, and twelve transcripts that record what the API really does, including the failures. ## Versions | Component | Version | |---|---| | Spring Boot | 4.1.2 | | Spring Framework (`spring-jdbc`) | 7.0.10 (7.0.0 reached Maven Central on 13 Nov 2025) | | HikariCP | 7.0.2 | | H2 | 2.4.240 | | JDK | 25 (Temurin 25.0.5) | ## Run it ```bash ./scripts/run-all.sh # runs the tests, which regenerate everything in output/ ``` No Docker and no database to install. Exception messages and a few behaviours (generated-key columns, the wording of constraint errors) are H2's; the shape of what Spring does is the same on other databases. ## Source | File | What it shows | |---|---| | [`ProductRepository.java`](src/main/java/com/ankurm/jdbcclient/ProductRepository.java) | the JdbcClient version: named parameters, `paramSource(record)`, `optional()`, generated keys, `stream()` | | [`ProductRepositoryJdbcTemplate.java`](src/main/java/com/ankurm/jdbcclient/ProductRepositoryJdbcTemplate.java) | the same operations with `JdbcTemplate` and `NamedParameterJdbcTemplate` | | [`StockService.java`](src/main/java/com/ankurm/jdbcclient/StockService.java) | two UPDATEs with and without `@Transactional` | | [`Product.java`](src/main/java/com/ankurm/jdbcclient/Product.java) | the record the rows map to | ## Captured output | File | Shows | |---|---| | [`01-same-results.txt`](output/01-same-results.txt) | both repositories return identical rows | | [`02-api-surface.txt`](output/02-api-surface.txt) | every method on `JdbcClient` and its spec interfaces, by reflection; there is no batch method | | [`03-parameters.txt`](output/03-parameters.txt) | nine ways to pass parameters and four ways to get them wrong | | [`04-mapping.txt`](output/04-mapping.txt) | records, beans, lambdas, missing columns, wrong types, SQL NULL into a primitive | | [`05-result-shapes.txt`](output/05-result-shapes.txt) | `list`, `single`, `optional`, `set` on 0, 1 and 4 rows | | [`06-generated-keys.txt`](output/06-generated-keys.txt) | `KeyHolder` with and without column names | | [`07-batch.txt`](output/07-batch.txt) | batching through `NamedParameterJdbcTemplate` | | [`08-exceptions.txt`](output/08-exceptions.txt) | what constraint violations and bad SQL turn into | | [`09-transactions.txt`](output/09-transactions.txt) | the same body with and without a transaction | | [`10-stream-leak.txt`](output/10-stream-leak.txt) | unclosed `stream()` calls exhausting a two-connection pool | | [`11-limits.txt`](output/11-limits.txt) | `withMaxRows` truncating silently, `withQueryTimeout` | | [`12-template-properties.txt`](output/12-template-properties.txt) | `spring.jdbc.template.max-rows` reaching the auto-configured `JdbcClient` | | [`13-api-diff.txt`](output/13-api-diff.txt) | `JdbcClient` signatures diffed across 6.1.0, 6.2.0, 6.2.19, 7.0.0 and 7.0.10 (`scripts/api-diff.sh`) | | [`14-default-jdbcclient.txt`](output/14-default-jdbcclient.txt) | the fields and constructors of `DefaultJdbcClient` in 7.0.10 (`scripts/api-diff.sh`) | `13` and `14` come from `./scripts/api-diff.sh`, which downloads the `spring-jdbc` jars from Maven Central and needs network access. Timings and the speed comparison in `07` are indicative: they vary between runs and H2 has no network round trip.