<?xml version=
"1.0" encoding=
"UTF-8"?>
<!DOCTYPE beans public "-//SPRING//DTD BEAN//EN"
"http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<!-- =========== Start of PERSISTENCE DEFINITIONS ============ -->
<bean id= "placeholderConfig" class= "org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name= "location">
<value>classpath:init.properties</value>
</property>
</bean>
<bean id= "nativeJdbcExtractor" class= "org.springframework.jdbc.support.nativejdbc.SimpleNativeJdbcExtractor"/>
<bean id= "oracleLobHandle" class= "org.springframework.jdbc.support.lob.OracleLobHandler" lazy-init= "true">
<property name= "nativeJdbcExtractor">
<ref local= "nativeJdbcExtractor"/>
</property>
</bean>
<bean id= "dataSource" class= "com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method= "close">
<property name= "driverClass">
<value>${datasource.driverClassName}</value>
</property>
<property name= "jdbcUrl">
<value>${datasource.url}</value>
</property>
<property name= "properties">
<props>
<prop key= "c3p0.minPoolSize">${hibernate.c3p0.minPoolSize}</prop>
<prop key= "hc3p0.maxPoolSize">${hibernate.c3p0.maxPoolSize}</prop>
<prop key= "hc3p0.timeout">${hibernate.c3p0.timeout}</prop>
<prop key= "c3p0.max_statement">${hibernate.c3p0.max_statement}</prop>
<prop key= "c3p0.testConnectionOnCheckout"> true</prop>
<prop key= "user">${datasource.username}</prop>
<prop key= "password">${datasource.password}</prop>
</props>
</property>
</bean>
<!-- Hibernate SessionFactory -->
<bean id= "sessionFactory" class= "org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name= "dataSource">
<ref local= "dataSource"/>
</property>
<property name= "lobHandler"><ref local= "oracleLobHandle"/></property>
<property name= "mappingResources">
<list>
<value>com/cs2c/oa2/pojo/Testfile.hbm.xml</value>
</list>
</property>
<property name= "hibernateProperties">
<props>
<prop key= "hibernate.cglib.use_reflection_optimizer">${hibernate.cglib.use_reflection_optimizer}</prop>
<prop key= "hibernate.connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</prop>
<prop key= "hibernate.dialect">${hibernate.dialect}</prop>
<prop key= "hibernate.default_schema">${hibernate.default_schema}</prop>
<prop key= "hibernate.show_sql">${hibernate.show_sql}</prop>
</props>
</property>
</bean>
<bean id= "test" class= "com.cs2c.oa2.test.TestHibernate">
<property name= "sessionFactory">
<ref bean= "sessionFactory"/>
</property>
</bean>
</beans>
在配置的时候 cp30的属性的名字必须是 ''driverClass' , 'jdbcUrl', 'user' , 'password' 而 <property name="properties">的名字也必须是“properties”,另外cp30配置文件的属性名也都是诸如:"c3p0.minPoolSize"、"hc3p0.maxPoolSize"等等,
<!DOCTYPE beans public "-//SPRING//DTD BEAN//EN"
"http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<!-- =========== Start of PERSISTENCE DEFINITIONS ============ -->
<bean id= "placeholderConfig" class= "org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name= "location">
<value>classpath:init.properties</value>
</property>
</bean>
<bean id= "nativeJdbcExtractor" class= "org.springframework.jdbc.support.nativejdbc.SimpleNativeJdbcExtractor"/>
<bean id= "oracleLobHandle" class= "org.springframework.jdbc.support.lob.OracleLobHandler" lazy-init= "true">
<property name= "nativeJdbcExtractor">
<ref local= "nativeJdbcExtractor"/>
</property>
</bean>
<bean id= "dataSource" class= "com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method= "close">
<property name= "driverClass">
<value>${datasource.driverClassName}</value>
</property>
<property name= "jdbcUrl">
<value>${datasource.url}</value>
</property>
<property name= "properties">
<props>
<prop key= "c3p0.minPoolSize">${hibernate.c3p0.minPoolSize}</prop>
<prop key= "hc3p0.maxPoolSize">${hibernate.c3p0.maxPoolSize}</prop>
<prop key= "hc3p0.timeout">${hibernate.c3p0.timeout}</prop>
<prop key= "c3p0.max_statement">${hibernate.c3p0.max_statement}</prop>
<prop key= "c3p0.testConnectionOnCheckout"> true</prop>
<prop key= "user">${datasource.username}</prop>
<prop key= "password">${datasource.password}</prop>
</props>
</property>
</bean>
<!-- Hibernate SessionFactory -->
<bean id= "sessionFactory" class= "org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name= "dataSource">
<ref local= "dataSource"/>
</property>
<property name= "lobHandler"><ref local= "oracleLobHandle"/></property>
<property name= "mappingResources">
<list>
<value>com/cs2c/oa2/pojo/Testfile.hbm.xml</value>
</list>
</property>
<property name= "hibernateProperties">
<props>
<prop key= "hibernate.cglib.use_reflection_optimizer">${hibernate.cglib.use_reflection_optimizer}</prop>
<prop key= "hibernate.connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</prop>
<prop key= "hibernate.dialect">${hibernate.dialect}</prop>
<prop key= "hibernate.default_schema">${hibernate.default_schema}</prop>
<prop key= "hibernate.show_sql">${hibernate.show_sql}</prop>
</props>
</property>
</bean>
<bean id= "test" class= "com.cs2c.oa2.test.TestHibernate">
<property name= "sessionFactory">
<ref bean= "sessionFactory"/>
</property>
</bean>
</beans>
在配置的时候 cp30的属性的名字必须是 ''driverClass' , 'jdbcUrl', 'user' , 'password' 而 <property name="properties">的名字也必须是“properties”,另外cp30配置文件的属性名也都是诸如:"c3p0.minPoolSize"、"hc3p0.maxPoolSize"等等,