日期:2014-05-16  浏览次数:20538 次

spring链接数据库applicationContext.xml配置
<?xml version="1.0" encoding="UTF-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"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
<!-- oracle 数据源配置-->

<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:@0.0.0.0:1521:ORCL2" />
<property name="user" value="ynyc" />
<property name="password" value="ynyc" />
<property name="maxIdleTime" value="1800" />
</bean>

<bean id="todoDao" class="com.chinasofti.ynyc.dao.impl.TodoDaoImpl">
<property name="dataSource">
<ref local="dataSource" />
</property>
</bean>

<bean id="todoService" class="com.chinasofti.ynyc.service.impl.TodoServiceImpl">
<property name="todoDao">
<ref local="todoDao" />
</property>
</bean>

</beans>