Connection pooling optimizes the time required to establish a connection with a database by creating a pool of reusable connections. It initially takes time to set up the connection pool but avoids repeatedly opening and closing connections, instead returning existing open connections from the pool. Most JDBC drivers and application servers support connection pooling through connection pool utilities like Apache Commons DBCP which is used to pool JDBC connections from a pool managed by the application server.