Embedding Derby in Struts 2 with Spring

Here's a quick and dirty way to embed a Derby instance in struts 2 using spring. I use the Apache dbcp for connection pooling, so that's what this example uses.

Spring creates singleton beans by default, so we can embed Derby and not run the Derby network server.

applicationContext.xml:

<bean id="configDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
        <property name="driverClassName"><value>org.apache.derby.jdbc.EmbeddedDriver</value></property>
        <property name="url"><value>jdbc:derby:/mydb;</value></property>
        <property name="poolPreparedStatements"><value>false</value></property>
        <property name="maxActive"><value>5</value></property>
        <property name="maxIdle"><value>5</value></property>
        <property name="maxWait"><value>40000</value></property>
	<property name="removeAbandoned"><value>true</value></property>
	<property name="removeAbandonedTimeout"><value>300</value></property>
	<property name="logAbandoned"><value>false</value></property>
</bean>

Note that you must pre-create your database and include it in the root of the war file.