开发者

What is best approach for connection pooling?

开发者 https://www.devze.com 2022-12-29 23:36 出处:网络
I am implementing connection pooling in project. Performance wise which 开发者_开发技巧is better approach to do it?

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.


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消