JNDI数据源配置注意事项

来源:互联网 发布:淘宝怎样看自己几颗心 编辑:程序博客网 时间:2024/06/06 03:18

如果是在原有工程上修改
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和工程的纽带是第三部分,如果想不一样,修改第三部分

如果是新建工程,tomcat也是新的,用这种方式的话,需要往tomcat中导入一些jar包

0 0
原创粉丝点击