Spring 之dataSource配置(jcbc,c3p0,dbcp,dndi)
1. jdbc配置
<bean id="dataSource" value="" /><property name="username" value="" /></bean>
<bean id="dataSource" destroy-method="close"> <property name="driverClassName" value="com.mysql.jdbc.Driver"/> <property name="url" value=""/> <property name="username" value="xx"/> <property name="password" value="xx"/> <property name="maxActive" value="120"/> <property name="initialSize" value="50"/> <property name="maxIdle" value="100"/> <property name="minIdle" value="100"/> <property name="maxWait" value="150"/> <property name="defaultAutoCommit" value="true"/> <property name="removeAbandoned" value="true"/> <property name="removeAbandonedTimeout" value="600"/> <property name="logAbandoned" value="true"/> <property name="validationQuery" value="SELECT 1"/> <property name="testOnBorrow" value="true" /> <property name="testOnReturn" value="false" /> <property name="testWhileIdle" value="true"/> <property name="timeBetweenEvictionRunsMillis" value="600000"/> <property name="minEvictableIdleTimeMillis" value="900000"/> </bean>
<bean id="dataSource" destroy-method="close"> <property name="driverClass" value="com.mysql.jdbc.Driver"/> <property name="jdbcUrl" value=""/> <property name="user" value="xx"/> <property name="password" value="xx"/> <property name="initialPoolSize" value="60" /> <property name="minPoolSize" value="50" /> <property name="maxPoolSize" value="100" /> <property name="maxIdleTime" value="7200" /> <property name="idleConnectionTestPeriod" value="360" /> <property name="preferredTestQuery" value="select 1" /> <property name="acquireIncrement" value="5" /> <property name="acquireRetryAttempts" value="50" /> <property name="acquireRetryDelay" value="1000" /> <property name="breakAfterAcquireFailure" value="true" /> <property name="checkoutTimeout" value="1000" /> <property name="autoCommitOnClose" value="false" /> <property name="forceIgnoreUnresolvedTransactions" value="false" /> <property name="unreturnedConnectionTimeout" value="1000" /> <property name="maxStatements" value="0" /> <property name="maxStatementsPerConnection" value="0" /> <property name="testConnectionOnCheckin" value="true" /> <property name="testConnectionOnCheckout" value="false" /> <property name="usesTraditionalReflectiveProxies" value="false" /> <property name="numHelperThreads" value="5" /> </bean>
<Resource name="jdbc/crm" author="Container" type="javax.sql.DataResource" drivermanager="oracle.jdbc.driver.OracleDriver" url="" username="" password="" maxActive="" maxidle="" maxWait="" />
<resource-ref> <res-ref-name>jdbc/crm</res-ref-name> <res-type>javax.sql.DataSource</res-type> <res-auth>Container</res-auth> </resource-ref>
<bean id="dataSource" value="java:comp/env/jdbc/crm" /><!-- 如果不想使用java:comp/env前缀的话设置为true <property name="recourceRef" value="true" />--></bean>