511-frameworks-micronaut-jdbc

Solid

Use when you need programmatic JDBC in Micronaut — pooled DataSource, parameterized SQL, io.micronaut.transaction.annotation.Transactional, batching, and domain exception translation. Part of the skills-for-java project

AI & Automation 393 stars 78 forks Updated today Apache-2.0

Install

View on GitHub

Quality Score: 92/100

Stars 20%
86
Recency 20%
100
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
50
License 10%
100
Description 5%
100

Skill Content

# Micronaut JDBC — programmatic SQL Apply programmatic JDBC patterns in Micronaut with safe SQL and clear transactions. **What is covered in this Skill?** - Injected javax.sql.DataSource (Hikari-backed with micronaut-jdbc-hikari) and try-with-resources for Connection / PreparedStatement - PreparedStatement with bind parameters — never string concatenation - Mapping ResultSet rows to Java records (dedicated mapRow method) - Safe single-row queries with Optional<T>; never assume rs.next() succeeds - SQLException translation to domain exceptions (catch-translate-rethrow) - Streaming large result sets with setFetchSize to avoid OOM - Batch updates with addBatch / executeBatch for bulk inserts - @Transactional service boundaries and TransactionDefinition.Propagation (e.g. REQUIRES_NEW for independent commits) - Self-invocation pitfall: call transactional collaborators through injected beans, not this.method() - SQL text blocks for multi-line SQL (upserts, dialect-specific clauses) - When to prefer Micronaut Data (`@512`) vs raw JDBC **Scope:** Apply recommendations based on the reference rules and good/bad code examples. ## Constraints Compile before JDBC refactors; verify after changes. - **MANDATORY**: Run `./mvnw compile` or `mvn compile` before applying any change - **PREREQUISITE**: Project must compile before applying JDBC improvements - **SAFETY**: If compilation fails, stop immediately - **BLOCKING CONDITION**: Compilation errors must be resolved by the user before ...

Details

Author
jabrena
Repository
jabrena/cursor-rules-java
Created
1 years ago
Last Updated
today
Language
Java
License
Apache-2.0

Integrates with

Similar Skills

Semantically similar based on skill content — not just same category

AI & Automation Solid

512-frameworks-micronaut-data

Use when you need data access with Micronaut Data — @MappedEntity, CrudRepository/PageableRepository, @Query with parameters, @Transactional services, projections, @Version, and @MicronautTest with TestPropertyProvider and Testcontainers. For raw java.sql access without generated repositories, use @511-frameworks-micronaut-jdbc. Part of the skills-for-java project

393 Updated today
jabrena
AI & Automation Solid

513-frameworks-micronaut-db-migrations-flyway

Use when you need to add or review Flyway database migrations in a Micronaut application — micronaut-flyway, db/migration scripts, flyway.datasources.* configuration, and alignment with JDBC or Micronaut Data. Part of the skills-for-java project

393 Updated today
jabrena
AI & Automation Solid

501-frameworks-micronaut-core

Use when building or reviewing Micronaut applications — Micronaut.run bootstrap, @Singleton/@Prototype, @Factory beans, @ConfigurationProperties, environments, @Requires, @Controller vs services, @Scheduled, graceful shutdown, @ExecuteOn for blocking work, and Jakarta-consistent APIs. Part of the skills-for-java project

393 Updated today
jabrena
AI & Automation Solid

411-frameworks-quarkus-jdbc

Use when you need programmatic JDBC in Quarkus — Agroal DataSource, parameterized SQL, transactions, batching, and Dev Services. Part of the skills-for-java project

393 Updated today
jabrena
AI & Automation Solid

311-frameworks-spring-jdbc

Use when you need to write or review programmatic JDBC with Spring — including JdbcClient (Spring Framework 7+) as the default API, JdbcTemplate only where batch/streaming APIs require JdbcOperations, NamedParameterJdbcTemplate for legacy named-param code, parameterized SQL, RowMapper mapping to records, batch operations, transactions, safe handling of generated keys, DataAccessException handling, read-only transactions, streaming large result sets, and @JdbcTest slice testing. This should trigger for requests such as Review Java code for Spring JDBC (JdbcTemplate, JdbcClient, NamedParameterJdbcTemplate); Apply best practices for Spring JDBC data access in Java code; Detect and fix SQL injection risks in JDBC code; Improve transaction boundaries or exception handling for JDBC operations. Part of cursor-rules-java project

393 Updated today
jabrena