Skip to main content

DataSource, Connection Pooling, Transactions with JDBC and Exception Translation

Learn DataSource, Connection Pooling, Transactions with JDBC and Exception Translation (Phase 16 · Spring JDBC and Data Access (Core), Spring Core) with worked examples, diagrams and interview questions. Free on JavaSchoolLab.

DataSource and connection pooling • A DataSource hands out connections. Never use DriverManagerDataSource in production (new connection per call). Use a connection pool : HikariCP (Boot default): maximumPoolSize (default 10), minimumIdle , connectionTimeout (30s), idleTimeout , maxLifetime (shorter than DB/ proxy timeout), leakDetectionThreshold . Pool sizing : small pools perform best (connections ≈ cores × 2 + disks); size to what the database can serve across all application instances.

More lessons in Phase 16 · Spring JDBC and Data Access (Core)