Both approaches are complementary, not mutually exclusive. On production systems like Spring / Hibernate, they will get a link to the connection pool from the application server as javax.sql.DataSource , usually looking for it in the JNDI tree. It is generally considered the “job” of a server application to manage the connection pool and its connections.
Remember that JNDI is just a place to register objects for sharing, it in itself provides the mandate of any connection pool mechanism. The application server creates and configures the pool, and applications (through Spring / Hibernate / other) use it.
This is also true for applications for setting up and managing a connection pool. This means that the application requires a bit more work, although it relies less on the application server.
source share