views:

361

answers:

1

I have been looking into connection pool options and it is somewhat unclear to me what the differences in Tomcat JNDI connection pool approach is, compared to the Spring/Hibernate solution to the same.

Whilst it's possible to achieve the pooling using either 1, 2, the specific application we have would lend itself better to us using Tomcat given the constraints we have.

Reading about, there is some suggestion to just stick with Spring/Hibernate.

Are there any notable differences worth mentioning between each approach? What are other's personal experience of one or the other (or both) - I have successfully been using Spring/Hibernate for years now.

+3  A: 

The two approaches are complementary, not mutually exclusive. In production systems, the likes of Spring/Hibernate will obtain a reference to the connection pool from the appserver, in the form of a javax.sql.DataSource, usually by looking for it on the JNDI tree. It generally considered to be the appserver's "job" to manage the connection pool and its connections.

Remember, JNDI is just a place for registering objects for sharing, it does in itself mandate any given connection pool mechanism. The app server creates and configures the pool, and the applications (via Spring/Hibernate/whatever) use it.

It's just as valid, however, for the applications to configure and manage the connection pool themselves. This does mean a bit more work for the application, though, with less reliance on the appserver.

skaffman
Fair enough, that makes sense. Now supposing I went with Tomcat JNDI based Pooling I assume therefore I would need to turn the pooling config in Spring off, in order not to pool on top of Tomcat's JNDI pooling... ?
j pimmel
Spring doesn't have a connection pool implementation, it uses whatever `DataSource` object you give it - if that happens to be a connection pool supplied by Tomcat via JNDI, so much the better.
skaffman
true, sorry I meant Hibernate
j pimmel
Oh right. Yes, Hibernate's connection pooling is strictly for development use, it's not intended for production systems - it says as much in the manual: http://docs.jboss.org/hibernate/stable/core/reference/en/html/session-configuration.html#configuration-hibernatejdbc
skaffman