Hello,
I am using C3P0 connection pooling in my app. I also use "org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean".
[CODE]<bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="persistenceUnitManager" ref="persistenceUnitManager" />
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
<property name="showSql" value="false" />
<property name="generateDdl" value="false" />
<property name="database" value="ORACLE"/>
<property name="databasePlatform" value="com.xxx.hibernate.OracleSpatialDialect" />
</bean>
</property>
<property name="persistenceUnitName" value="dcPersistenceUnitTest" />
</bean>
[/CODE]
[CODE]<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
<property name="driverClass" value="oracle.jdbc.driver.OracleDriver" />
<property name="jdbcUrl" value="${dc.url}" />
<property name="user" value="${dc.user}" />
<property name="password" value="${dc.password}" />
<!-- C3P0 connection pool configuration -->
<property name="minPoolSize" value="5"/>
<property name="maxPoolSize" value="20"/>
<property name="checkoutTimeout" value="300"/>
<property name="maxStatements" value="50"/>
<property name="maxIdleTime" value="300"/>
</bean>
[/CODE]
However, it will NOT work for the statement below.
[CODE]
OracleConnection oc = (OracleConnection) preparedStatement.getConnection();
[/CODE]
So, I went through Spring documentation 3.x, it suggests that it can be done by using C3P0NativeJdbcExtractor.
I did some research on how to configure it in spring applicationContext.xml, however, I couldn't find anything using entityManagerFactory.
I am not quite sure where to use the following:
[CODE]<bean id="defaultLobHandler" class="org.springframework.jdbc.support.lob.DefaultLobHandler" lazy-init="true"/>
<!-- LobHandler for Oracle JDBC drivers -->
<!-- (refers to the NativeJdbcExtractor above to get access to native OracleConnections) -->
<bean id="oracleLobHandler" class="org.springframework.jdbc.support.lob.OracleLobHandler" lazy-init="true">
<property name="nativeJdbcExtractor" ref="nativeJdbcExtractor"/>
</bean>
<!-- NativeJdbcExtractor for the C3P0 connection pool above -->
<!-- (just needed for oracleLobHandler) -->
<bean id="nativeJdbcExtractor" class="org.springframework.jdbc.support.nativejdbc.C3P0NativeJdbcExtractor"
lazy-init="true"/>
[/CODE]
Please advice.
Thank you.
Hello,
I am using C3P0 connection pooling in my app. I also use "org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean".
[CODE]<bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="persistenceUnitManager" ref="persistenceUnitManager" />
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
<property name="showSql" value="false" />
<property name="generateDdl" value="false" />
<property name="database" value="ORACLE"/>
<property name="databasePlatform" value="com.xxx.hibernate.OracleSpatialDialect" />
</bean>
</property>
<property name="persistenceUnitName" value="dcPersistenceUnitTest" />
</bean>
[/CODE]
[CODE]<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
<property name="driverClass" value="oracle.jdbc.driver.OracleDriver" />
<property name="jdbcUrl" value="${dc.url}" />
<property name="user" value="${dc.user}" />
<property name="password" value="${dc.password}" />
<!-- C3P0 connection pool configuration -->
<property name="minPoolSize" value="5"/>
<property name="maxPoolSize" value="20"/>
<property name="checkoutTimeout" value="300"/>
<property name="maxStatements" value="50"/>
<property name="maxIdleTime" value="300"/>
</bean>
[/CODE]
However, it will NOT work for the statement below.
[CODE]
OracleConnection oc = (OracleConnection) preparedStatement.getConnection();
[/CODE]
So, I went through Spring documentation 3.x, it suggests that it can be done by using C3P0NativeJdbcExtractor.
I did some research on how to configure it in spring applicationContext.xml, however, I couldn't find anything using entityManagerFactory.
I am not quite sure where to use the following:
[CODE]<bean id="defaultLobHandler" class="org.springframework.jdbc.support.lob.DefaultLobHandler" lazy-init="true"/>
<!-- LobHandler for Oracle JDBC drivers -->
<!-- (refers to the NativeJdbcExtractor above to get access to native OracleConnections) -->
<bean id="oracleLobHandler" class="org.springframework.jdbc.support.lob.OracleLobHandler" lazy-init="true">
<property name="nativeJdbcExtractor" ref="nativeJdbcExtractor"/>
</bean>
<!-- NativeJdbcExtractor for the C3P0 connection pool above -->
<!-- (just needed for oracleLobHandler) -->
<bean id="nativeJdbcExtractor" class="org.springframework.jdbc.support.nativejdbc.C3P0NativeJdbcExtractor"
lazy-init="true"/>
[/CODE]
Please advice.
Thank you.