Last Updated: June 6, 2026
A database connection looks cheap from inside your code: one line opens it, one line closes it. The wire-level reality is the opposite. Opening a real database connection costs a TCP handshake plus an authentication round trip plus session setup, and that bill comes due every single time. This lesson is about why a connection pool is the standard answer, how the pool's lifecycle differs from the raw DriverManager model, and how to wire up HikariCP against an H2 in-memory shop database so the rest of your code never thinks about connections again.