20120126 Thursday January 26, 2012

Using H2 connection pool in Spring

H2 is bundled with a built-in connection pool implementation. The following XML provides an example of using it as a Datasource bean without a need to introduce additional dependencies on DBCP or C3P0:

    <bean id="dataSource" class="org.h2.jdbcx.JdbcConnectionPool" destroy-method="dispose">
        <constructor-arg>
            <bean class="org.h2.jdbcx.JdbcDataSource">
                <property name="URL" value="jdbc:h2:dbname"/>
                <property name="user" value="user"/>
                <property name="password" value="password"/>
             </bean>
        </constructor-arg>
    </bean>

The database will be shut down by calling a dispose method when Spring application context closes.

( Jan 26 2012, 05:08:44 PM GMT+02:00 ) Permalink AddThis Social Bookmark Button Add to DZone
Comments:

Post a Comment:

Comments are closed for this entry.