1. Learn
  2. /
  3. Courses
  4. /
  5. Querying a PostgreSQL Database in Java

Connected

Exercise

Connection Pooling

Opening a new database connection for every request is slow and resource-intensive. Connection pooling solves this by reusing a pool of open connections. HikariCP is a popular, high-performance connection pool for Java applications.

Set up HikariCP for CityBook Libraries to improve their application's performance. HikariConfig, HikariDataSource, and database credentials are already imported for you.

Instructions

100 XP
  • Configure HikariConfig with the database URL, username, and password.
  • Create a HikariDataSource from the configuration.
  • Get a connection from the pool.