Hi there,
I had the basic DriverManagerDataSource working with Oracle client encryption, as follows:
I wanted to add connection pooling so I switched to a c3p0 ComboPooledDataSource, but now I can't figure out how to set up the oracle encryption driver properties.Code:<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource" p:driverClassName="oracle.jdbc.OracleDriver" p:url="${CONNECTION_STRING}" p:username="${DB_USERNAME}" p:password="${DB_PASSWORD}"> <property name="connectionProperties"> <value> oracle.net.encryption_types_client: (RC4_256) oracle.net.encryption_client: REQUIRED oracle.net.crypto_checksum_types_client: (MD5) oracle.net.crypto_checksum_client: REQUIRED oracle.net.crypto_seed: 123456 </value> </property> </bean>
I tried adding them as shown in the next code block, but I got java.sql.SQLException: ORA-01017: invalid username/password, and c3p0 goes into deadlock. So, I currently have them commented out, and the connection pooling works fine.
In this blog post: http://forum.springsource.org/showth...highlight=c3p0Code:<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close"> <property name="driverClass" value="oracle.jdbc.OracleDriver" /> <property name="jdbcUrl" value="${CONNECTION_STRING}" /> <property name="user" value="${DB_USERNAME}" /> <property name="password" value="${DB_PASSWORD}" /> <!-- c3p0 properties --> <property name="initialPoolSize" value="5" /> <property name="minPoolSize" value="5" /> <property name="maxPoolSize" value="20" /> <property name="acquireIncrement" value="5" /> <property name="maxIdleTime" value="600" /> <property name="idleConnectionTestPeriod" value="600" /> <!-- <property name="properties"> <value> oracle.net.encryption_types_client: (RC4_256) oracle.net.encryption_client: REQUIRED oracle.net.crypto_checksum_types_client: (MD5) oracle.net.crypto_checksum_client: REQUIRED oracle.net.crypto_seed: 123456 </value> </property> --> </bean>
Someone suggested using a connectionCustomizerClassName:
However, since onAcquire runs AFTER the connection has been established, that doesn't seem like the right place to pass the oracle encryption parameters to the driver.Code:<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close"> <property name="driverClass" value="${jdbc.driverClassName}"/> <property name="jdbcUrl" value="${jdbc.url}"/> <property name="user" value="${jdbc.username}"/> <property name="password" value="${jdbc.password}"/> <property name="preferredTestQuery" value="${jdbc.validationQuery}"/> <property name="connectionCustomizerClassName" value="com.example.OracleConnectionCustomizer"/> </bean> public class OracleConnectionCustomizer extends AbstractConnectionCustomizer { @Override public void onAcquire( Connection connection, String parentDataSourceIdentityToken) throws Exception { // Follow synonyms when retrieving metadata. ((OracleConnection) connection).setIncludeSynonyms(true); } }
Any suggestions? Am I missing something?
Thanks,
Jose


Reply With Quote