Using c3p0 database pool
From Resin 4.0 Wiki
(Difference between revisions)
(Created page with "Category:Resin:_3rd_Party_Integration link=Category:Resin:_3rd_Party_Integration = Using a c3p0 datasource in Resin, bound into JNDI = This config...") |
|||
Line 21: | Line 21: | ||
<maxPoolSize>5</maxPoolSize> | <maxPoolSize>5</maxPoolSize> | ||
</c3p0:ComboPooledDataSource> | </c3p0:ComboPooledDataSource> | ||
+ | |||
+ | You can then reference the pool by the JNDI name "java:comp/env/jdbc/mysql". For eample in JPA persistence.xml: | ||
+ | |||
+ | <jta-data-source>java:comp/env/jdbc/mysql</jta-data-source> |
Latest revision as of 13:31, 5 September 2013
Using a c3p0 datasource in Resin, bound into JNDI
This configuration can go in resin.xml as a child of <cluster>, <host>, or <web-app>, or in resin-web.xml. Where you put it depends on how globally you want the pool to be shared between webapps.
You may need to add the c3p0 jar to /var/resin/lib, the main Resin shared lib directory, since the pool will be created as a shared resource upon startup.
In the top XML element, define the c3p0 namespace by adding:
xmlns:c3p0="urn:java:com.mchange.v2.c3p0"
Then create the pool:
<c3p0:ComboPooledDataSource resin:Jndi="java:comp/env/jdbc/mysql"> <driverClass>com.mysql.jdbc.Driver</driverClass> <jdbcUrl>jdbc:mysql://address:3306/schema</jdbcUrl> <user>user</user> <password>password</password> <minPoolSize>3</minPoolSize> <maxPoolSize>5</maxPoolSize> </c3p0:ComboPooledDataSource>
You can then reference the pool by the JNDI name "java:comp/env/jdbc/mysql". For eample in JPA persistence.xml:
<jta-data-source>java:comp/env/jdbc/mysql</jta-data-source>