diff --git a/src/main/webapp/WEB-INF/applicationContext-hibernate.xml b/src/main/webapp/WEB-INF/applicationContext-hibernate.xml index bfc166db6253d6a10eed9680f488b8adb2b15285..39a939aada67c2bb7c7aa858b22f69c18d6af1c8 100644 --- a/src/main/webapp/WEB-INF/applicationContext-hibernate.xml +++ b/src/main/webapp/WEB-INF/applicationContext-hibernate.xml @@ -6,10 +6,10 @@ xmlns:p="http://www.springframework.org/schema/p" xmlns:context="http://www.springframework.org/schema/context" xmlns:jee="http://www.springframework.org/schema/jee" xmlns:tx="http://www.springframework.org/schema/tx" xsi:schemaLocation=" - http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd - http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd - http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.5.xsd - http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd"> + http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd + http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd + http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee.xsd + http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd"> <!-- ========================= RESOURCE DEFINITIONS ========================= --> @@ -22,10 +22,18 @@ for the required JAR files. Alternatively you can use another connection pool such as C3P0, similarly configured using Spring. --> + + <bean id="dataSource" class="org.springframework.samples.petclinic.config.DbcpDataSourceFactory" + p:driverClassName="${jdbc.driverClassName}" p:url="${jdbc.url}" + p:username="${jdbc.username}" p:password="${jdbc.password}" p:populate="${jdbc.populate}" + p:schemaLocation="${jdbc.schemaLocation}" p:dataLocation="${jdbc.dataLocation}"/> + + <!-- DataSource configuration for Apache Commons DBCP. --> + <!-- <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close" p:driverClassName="${jdbc.driverClassName}" p:url="${jdbc.url}" p:username="${jdbc.username}" p:password="${jdbc.password}"/> - + --> <!-- JNDI DataSource for JEE environments --> <!-- <jee:jndi-lookup id="dataSource" jndi-name="java:comp/env/jdbc/petclinic"/> diff --git a/src/main/webapp/WEB-INF/applicationContext-jdbc.xml b/src/main/webapp/WEB-INF/applicationContext-jdbc.xml index 69a2b1f5dcc7f75389f272eb4bc25ede55ba02ff..e2b9bb4f7d92651205b31e5becc1d101926bde29 100644 --- a/src/main/webapp/WEB-INF/applicationContext-jdbc.xml +++ b/src/main/webapp/WEB-INF/applicationContext-jdbc.xml @@ -7,11 +7,11 @@ xmlns:context="http://www.springframework.org/schema/context" xmlns:jee="http://www.springframework.org/schema/jee" xmlns:tx="http://www.springframework.org/schema/tx" xsi:schemaLocation=" - http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd - http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd - http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd - http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.5.xsd - http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd"> + http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd + http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd + http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd + http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee.xsd + http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd"> <!-- ========================= RESOURCE DEFINITIONS ========================= --> @@ -32,6 +32,12 @@ p:username="${jdbc.username}" p:password="${jdbc.password}" p:populate="${jdbc.populate}" p:schemaLocation="${jdbc.schemaLocation}" p:dataLocation="${jdbc.dataLocation}"/> + <!-- DataSource configuration for Apache Commons DBCP. --> + <!-- + <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close" + p:driverClassName="${jdbc.driverClassName}" p:url="${jdbc.url}" p:username="${jdbc.username}" + p:password="${jdbc.password}"/> + --> <!-- JNDI DataSource for JEE environments --> <!-- <jee:jndi-lookup id="dataSource" jndi-name="java:comp/env/jdbc/petclinic"/> diff --git a/src/main/webapp/WEB-INF/applicationContext-jpa.xml b/src/main/webapp/WEB-INF/applicationContext-jpa.xml index 25374e9abe2cf717be38eb4dae3a3ec95b852175..5b2be5ecd1bdefe3ea4464cb5ccf0501a9b1d9f6 100644 --- a/src/main/webapp/WEB-INF/applicationContext-jpa.xml +++ b/src/main/webapp/WEB-INF/applicationContext-jpa.xml @@ -7,11 +7,11 @@ xmlns:context="http://www.springframework.org/schema/context" xmlns:jee="http://www.springframework.org/schema/jee" xmlns:tx="http://www.springframework.org/schema/tx" xsi:schemaLocation=" - http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd - http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd - http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd - http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.5.xsd - http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd"> + http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd + http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd + http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd + http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee.xsd + http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd"> <!-- ========================= RESOURCE DEFINITIONS ========================= --> @@ -27,14 +27,24 @@ <context:property-placeholder location="classpath:jdbc.properties"/> <!-- - Uses Apache Commons DBCP for connection pooling. See Commons DBCP documentation - for the required JAR files. Alternatively you can use another connection pool - such as C3P0, similarly configured using Spring. + Spring FactoryBean that creates a DataSource using Apache Commons DBCP for connection + pooling. See Commons DBCP documentation for the required JAR files. This factory bean + can populate the data source with a schema and data scripts if configured to do so. + + An alternate factory bean can be created for different connection pool implementations, + C3P0 for example. --> + <bean id="dataSource" class="org.springframework.samples.petclinic.config.DbcpDataSourceFactory" + p:driverClassName="${jdbc.driverClassName}" p:url="${jdbc.url}" + p:username="${jdbc.username}" p:password="${jdbc.password}" p:populate="${jdbc.populate}" + p:schemaLocation="${jdbc.schemaLocation}" p:dataLocation="${jdbc.dataLocation}"/> + + <!-- DataSource configuration for Apache Commons DBCP. --> + <!-- <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close" p:driverClassName="${jdbc.driverClassName}" p:url="${jdbc.url}" p:username="${jdbc.username}" p:password="${jdbc.password}"/> - + --> <!-- JNDI DataSource for JEE environments --> <!-- <jee:jndi-lookup id="dataSource" jndi-name="java:comp/env/jdbc/petclinic"/> diff --git a/src/main/webapp/WEB-INF/petclinic-servlet.xml b/src/main/webapp/WEB-INF/petclinic-servlet.xml index 3c05fc3000369aebd1021bbe2216ab08de253baa..e55766ac43bccd7c200c16e4f1677b2e848e868c 100644 --- a/src/main/webapp/WEB-INF/petclinic-servlet.xml +++ b/src/main/webapp/WEB-INF/petclinic-servlet.xml @@ -5,8 +5,8 @@ <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" xmlns:context="http://www.springframework.org/schema/context" xmlns:oxm="http://www.springframework.org/schema/oxm" - xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd - http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd + xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd + http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/oxm http://www.springframework.org/schema/oxm/spring-oxm-3.0.xsd"> <!--