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

DBCP配置方法(Oracle下)

1.修改Tomcat的context.xml,加入以下配置

<Resource
name="jdbc/oracle"
auth="Container"
type="javax.sql.DataSource"
maxActive="1000"
maxIdle="30"
maxWait="10000"
username="tech"
password="pwd"
driverClassName="oracle.jdbc.driver.OracleDriver"
validationQuery = "select 1 from dual "
testOnBorrow = "true"
testOnReturn = "false"
testWhileIdle = "true"
timeBetweenEvictionRunsMillis = "15000"
numTestsPerEvictionRun = "10"
minEvictableIdleTimeMillis = "600000"
url="jdbc:oracle:thin:@localhost:1521:ORA921"
/>

?

2.修改spring配置文件,加入以下配置:

?

   <bean id="dataSource"
        class="org.springframework.jndi.JndiObjectFactoryBean">
        <property name="jndiName">
        <value>java:comp/env/jdbc/oracle</value>
        </property>
     </bean>
?

DPCP详细配置:http://commons.apache.org/dbcp/configuration.html

?