Passing connection properties in HikariJNDIFactory

723 views
Skip to first unread message

Flavio Campana

unread,
Jun 19, 2015, 6:40:57 AM6/19/15
to hika...@googlegroups.com
Hi,
i have the need to pass specific connection properties thru HikariJNDIFactory.

In tomcat jdbc there is a connection properties that is evaluated again and then passed on to the connection, like this:

<Resource name="jdbc/Oracle" auth="Container"
       
factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"
 
localDataSource="true" type="javax.sql.DataSource" maxActive="25"
 
maxIdle="10" maxWait="10000" username="user" password="pass"
 
driverClassName="oracle.jdbc.OracleDriver" url="jdbc:oracle:thin:@host:1521:orcl"
   
connectionProperties="oracle.jdbc.timezoneAsRegion=false;fixedString=true"/>

Is there anything similar in Hikari?
I tried looking in the code but haven't found anything.

Thanks

Brett Wooldridge

unread,
Jun 19, 2015, 9:53:59 AM6/19/15
to hika...@googlegroups.com, silv...@gmail.com
Everything prefixed "dataSource." is put into a Properties and passed into the driver.
<Resource name="jdbc/OracleHikari" auth="Container"
      factory="com.zaxxer.hikari.HikariJNDIFactory"
      type="javax.sql.DataSource"
      minimumIdle="5" 
      maximumPoolSize="10"
      connectionTimeout="300000"
      jdbcUrl="jdbc:oracle:thin:@orcl_server:1521:orcl"
      dataSource.implicitCachingEnabled="true" 
      dataSource.user="user"
      dataSource.password="pwd" />
In this example, the "dataSource." will be striped from those properties, and the remaining key and value added to a Properties instance ... the equivalent of this:

Properties driverProperties = new Properties();
driverProperties.setProperty("implicitCachingEnable", "true");
driverProperties.setProperty("user", "true");
driverProperties.setProperty("password", "true");

And finally, whenever a connection is created then those properties are passed in...

driver.connect(jdbcUrl, driverProperties);


Reply all
Reply to author
Forward
0 new messages