Why is Oracle PoolDataSource ignoring connectionProperties values?

In my contex.xml file for Tomcat I have this datasource declaration:

<Resource name="jdbc/my_ds" auth="Container" factory="oracle.ucp.jdbc.PoolDataSourceImpl" 
          type="oracle.ucp.jdbc.PoolDataSource" description="UCP Pool in Tomcat" 
          connectionFactoryClassName="oracle.jdbc.pool.OracleDataSource" minPoolSize="1" maxPoolSize="10" 
          initialPoolSize="2" inactiveConnectionTimeout="20" setMaxIdleTime="1800" 
          user="my_user" password="my_password" 
          url="jdbc:oracle:thin:@mydb.com:1234:DATABASEID" connectionPoolName="MY_UCPPool" 
          connectionProperties="defaultBatchValue=7000,defaultRowPrefetch=7000" validateConnectionOnBorrow="true"/>

      

But in my DAO code, when I check the sample size, it doesn't return 7000 as expected:

if (s.getFetchSize() < 100) {
   log.warn("fetch size is too small: " + s.getFetchSize());
}

      

+3


source to share


1 answer


After decompiling the PoolDataSourceImpl class, I found this piece of code:

propStrs = cfPropsStr.substring(1, cfPropsStr.length() - 1).split(", ");

      

when it parses the content of connectionProperties.

It means that:

  • Separator ",", not ","
  • The first and last characters are discarded

Therefore, you just need to change the declaration:

connectionProperties="defaultBatchValue=7000,defaultRowPrefetch=7000"

      



in

connectionProperties=" defaultBatchValue=7000, defaultRowPrefetch=7000 "

      

or even:

connectionProperties="_defaultBatchValue=7000, defaultRowPrefetch=7000_"

      

Please note that there is no need to use leading or trailing spaces, it can be any character.

With the original configuration, the result is the key "efaultBatchValue" and the value "7000, defaultRowPrefetch = 700".

+4


source







All Articles