JDBC (Java Database Connectivity) is the Java API used to issue SQL statements to a relational database. Whether SQL is handwritten or generated by Java code, JDBC handles low-level work such as binding query parameters, executing queries, navigating results, and retrieving values. That work is necessary for data access, but it is often not the business logic an application is trying to express. section 1.1.3
Choosing where to handle that work changes the persistence code:
- With direct JDBC, application code must manage service tasks such as opening and closing connections and handling exceptions. section 15.0
- Hibernate and JPA address object/relational mapping so code can work with persistent objects rather than hand-code every CRUD operation in SQL and JDBC. section 1.0 section 1.1.3
- Spring Data JDBC offers JDBC-based repositories and SQL queries with a simpler, more limited mapping model than JPA: it has no caching, lazy loading, sessions, or dirty tracking, and entities must be saved explicitly. section 15.0
JDBC also provides a partial abstraction over vendor-specific SQL data types. Hibernate can use ANSI-standard types when executing INSERT and UPDATE statements, while its configured SQL dialect translates types for product-specific schema generation. That distinction matters when working with an existing schema or writing vendor-specific SQL; Spring Data JDBC queries use plain SQL and do not gain query portability from its repository API. section 6.3.1 section 15.0
A type-mapping boundary
A Java BigDecimal property maps to the standard SQL NUMERIC type. For schema generation with Hibernate’s H2 dialect, NUMERIC is translated to DECIMAL with precision and scale. JDBC helps abstract the data type used during data manipulation; the dialect determines the database-specific schema type. section 6.3.1
Table 6.1 Java primitive types that map to SQL standard types (view table figure)
Compare Java numeric types with the ANSI SQL types used in Hibernate’s built-in mappings. section 6.3.1

