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?
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?
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.
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>
<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"/>
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.