What is best approach for connection pooling?

孤街浪徒 提交于 2019-12-20 03:39:07

问题


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.


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/2826575/what-is-best-approach-for-connection-pooling

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!