views:

90

answers:

3

I am implementing connection pooling in project. Performance wise which is better approach to do it?

  • Hibernate (using C3PO or DBCP)
  • Configuring JDBC data-source in Application server.

Application server Portability is not an important factor for me. Please suggest the approach.

A: 

that depends whether your 'application' server supports pooling. for example, tomcat doesn't (as it's not a proper app server), but glassfish does. as an aside, i personally have found c3po much better than dbcp, but it's worth testing them both in your environment.

oedo
A: 

Connection pooling is implemented in the DataSource, and in both case Hibernate will use a datasource.

The question is which data source implementation is used, and how is it configured:

  1. You can specify and configure the datasource right into the hibernate configuration
  2. You can configure the datasource in the app. server, and specify the corresponding JNDI names in the hibernate configuration. In this case you use the datasource implementation that ships with the app. server.

Performance-wise, I think the implementation has little impact -- it's more whether you want your .war to be dependent on resources managed by the app. server (case 2) or not (case 1). In case 1, prefer C3P0 to DBCP though.

ewernli