JNDI数据源配置注意事项

时间:2021-10-18 22:45:56

假设是在原有project上改动

1,applicationContext.xml中改动当中的value值

<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">

     <property name="jndiName">

     <value>java:comp/env/jndivalue</value>

     </property>

 </bean>

2,web.xml中改动res-ref-name

<resource-ref>

  <res-ref-name>jndivalue</res-ref-name>

  <res-type>javax.sql.DataSource</res-type>

  <res-auth>Container</res-auth>

 </resource-ref>

3,tomcat中,conf/context.xml中改动或加入

<ResourceLink name="jndivalue" global="jndivalue" type="javax.sql.DataSource"/>

4,tomcat中,conf/server.xml中 <GlobalNamingResources> </GlobalNamingResources>中加入

<Resource name="jndivalue" auth="Container"     

   type="com.jolbox.bonecp.BoneCPDataSource"   

   factory="org.apache.naming.factory.BeanFactory"  

   driverClass="oracle.jdbc.driver.OracleDriver"

   username=""  password=""

   jdbcUrl=""  

   idleMaxAge="240"

   idleConnectionTestPeriod="60"

   partitionCount="3"

   acquireIncrement="10"

   minConnectionsPerPartition="10"    

   maxConnectionsPerPartition="20"

   releaseHelperThreads="3"/>

这四部分的jndivalue最好是统一的,tomcat和project的纽带是第三部分,假设想不一样,改动第三部分

假设是新建project,tomcat也是新的,用这样的方式的话,须要往tomcat中导入一些jar包