Configure HikariCP as a DataSource Factory for Tomcat?

2,644 views
Skip to first unread message

Martin Cordova

unread,
Apr 24, 2014, 8:38:34 AM4/24/14
to hika...@googlegroups.com
Hello, is it possible to configure HikariCP as a Resource in Tomcat's context.xml file?

I just did it with DBCP V2 (not included in Tomcat 7):

<Context>

<Resource name="jdbc/dinamica" auth="Container" type="javax.sql.DataSource" 
factory="org.apache.commons.dbcp2.BasicDataSourceFactory"
initialSize="3" maxActive="100" maxIdle="10" maxWait="3000" maxTotal="100"
username="xxxxxx" password="xxxxx" 
driverClassName="org.postgresql.Driver"
url="jdbc:postgresql://localhost/demodb"/>

</Context>

I had to change maxActive attribute to maxTotal, and add the factory attribute. It works OK, assuming the required JARs are added to the lib folder.

I wonder if something similar can be done with HikariCP?

Regards,
Martin
--
Dinamica Framework

Brett Wooldridge

unread,
Apr 24, 2014, 9:56:16 AM4/24/14
to hika...@googlegroups.com
Maybe a Tomcat user can jump in here and answer.  I know we have several Tomcat users, as in the past they've opened issues (that have been fixed).


Brett Wooldridge

unread,
Apr 24, 2014, 8:24:14 PM4/24/14
to hika...@googlegroups.com
I have checked in a JNDI factory (com.zaxxer.hikari.HikariJNDIFactory) similar to the one provided by Tomcat.  It is in the 'dev' branch and is untested, but if you'd try it out an tell me if it work (or what errors you get), it would be appreciated.

cd HikariCP
git checkout dev
mvn install

Then use 1.3.7-SNAPSHOT as your version dependency, or use the HikariCP-1.3.7-SNAPSHOT.jar from the target directory.

Brett Wooldridge

unread,
Apr 28, 2014, 4:28:09 AM4/28/14
to hika...@googlegroups.com
This feature can be found in the 1.3.8 release of HikariCP available in maven central repository.

Reply all
Reply to author
Forward
0 new messages