eclipselink connection pooling

℡╲_俬逩灬. 提交于 2019-12-18 02:09:13

问题


If connection pooling is not defined in the persistence.xml for eclipse link, what is the default behavior?

Will it open and close a JDBC connection for every transaction? Will it create a connection pool with some defaults?


回答1:


The default connection pooling for EclipseLink when not using a data source is a pool of min/max 32 connections, with an initial of 1 connections. So each transaction will use a pooled connection, and not connect/disconnect.




回答2:


If you use an application server (Java EE) and container managed persistence, then you need to set up the connection pooling in the administration console of the application server, and don't need to set the pooling properties in the persistence.xml, e.g.:

<persistence-unit name="myPU" transaction-type="JTA">
  <jta-data-source>jdbc_my_DataSource</jta-data-source>
  <exclude-unlisted-classes>false</exclude-unlisted-classes>
  <shared-cache-mode>NONE</shared-cache-mode>
  <properties/>
</persistence-unit>

If you use EclipseLink without application server (Java SE), using application managed persistence, then if you don't configure pooling, Internal Connection Pooling will be used, e.g.:

<persistence-unit name="DemoPU" transaction-type="RESOURCE_LOCAL">
  <properties>
    <property name="javax.persistence.jdbc.url" value="jdbc:oracle:thin:@localhost:1521:xe"/>
    <property name="javax.persistence.jdbc.user" value="myuser"/>
    <property name="javax.persistence.jdbc.password" value="mypassword"/>
    <property name="javax.persistence.jdbc.driver" value="oracle.jdbc.OracleDriver"/>
  </properties>
</persistence-unit>



回答3:


<property name="eclipselink.connection-pool.default.initial" value="1"/>
<property name="eclipselink.connection-pool.default.min" value="64"/>
<property name="eclipselink.connection-pool.default.max" value="64"/>



回答4:


Just wanted to provide the code source for James' answer above: You can see that a default connection pool is created in the constructors of ServerSession, using the init/min/max defaults defined in ConnectionPool, and optionally overridden/adjusted by the developer via properties in EntityManagerSetupImpl.



来源:https://stackoverflow.com/questions/15119095/eclipselink-connection-pooling

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