Spring结合Hibernate配置C3P0数据源

<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">       
	<property name="driverClass" value="oracle.jdbc.driver.OracleDriver"/>       
	<property name="jdbcUrl" value="jdbc:oracle:thin:@localhost:1521:ORCL"/>       
	<property name="user" value="spring2"/>       
	<property name="password" value="spring2"/>  
	
	
	<!-- 连接关闭时默认将所有未提交的操作回滚。默认为false -->
	<property name="autoCommitOnClose" value="true"/> 
	
	<!-- 连接池中保留的最小连接数-->
	<property name="minPoolSize" value="2"/>
	
	<!-- 连接池中保留的最大连接数。默认为15 -->      
	<property name="maxPoolSize" value="15"/>  
	
	<!-- 初始化时获取的连接数,取值应在minPoolSize与maxPoolSize之间。默认为3 -->
	<property name="initialPoolSize" value="3"/>  
	
	<!-- 最大空闲时间,超过空闲时间的连接将被丢弃。为0或负数则永不丢弃。默认为0秒 -->
	<property name="maxIdleTime" value="60"/>      
	
	<!-- 当连接池中的连接用完时,C3P0一次性创建新连接的数目。默认为3 -->
	<property name="acquireIncrement" value="3"/>      
	
	<!-- 定义在从数据库获取新连接失败后重复尝试获取的次数,默认为30 -->
	<property name="acquireRetryAttempts" value="3"/>    
	 
	<!-- 当连接池用完时客户端调用getConnection()后等待获取新连接的时间,超时后将抛出SQLException,如设为0则无限期等待。单位毫秒,默认为0 -->
	<property name="checkoutTimeout" value="10000"/>     
</bean>

 

<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
	<property name="dataSource" ref="dataSource" />
	<property name="mappingDirectoryLocations">
		<list>
			<value>WEB-INF/config/mapping/base/</value>
			<value>WEB-INF/config/mapping/jbpm/</value>
		</list>
	</property>
	<property name="hibernateProperties">
		<props>
			<prop key="hibernate.dialect">org.hibernate.dialect.OracleDialect</prop>
			<prop key="hibernate.show_sql">true</prop>
			<prop key="hibernate.format_sql">false</prop>
			<prop key="hibernate.generate_statistics">true</prop>
			<prop key="hibernate.connection.release_mode">auto</prop>
			<prop key="hibernate.autoReconnect">true</prop>
			<prop key="hibernate.transaction.flush_before_completion">true</prop>
			<prop key="hibernate.cache.use_second_level_cache">false</prop>
			<prop key="hibernate.cache.use_query_cache">false</prop>
		</props>
	</property>
</bean>

 

你可能感兴趣的:(spring,oracle,Hibernate,bean,jbpm)