Java,J2EE,Weblogic,Oracle

java项目随笔
随笔 - 90, 文章 - 6, 评论 - 61, 引用 - 0
数据加载中……

spring 使用 tomcat5.X 的全局DataSource的jndi

1、tomcat安装目录\conf\ server.xml
<GlobalNamingResources>
    <Environment
      name="simpleValue"
      type="java.lang.Integer"
      value="30"/>
    <Resource
      auth="Container"
      description="User database that can be updated and saved"
      name="UserDatabase"
      type="org.apache.catalina.UserDatabase"
      pathname="conf/tomcat-users.xml"
      factory="org.apache.catalina.users.MemoryUserDatabaseFactory"/>
    <Resource
      name="jdbc/VoteDB"
      type="javax.sql.DataSource"
      password="test"
      driverClassName="oracle.jdbc.driver.OracleDriver"
      maxIdle="3"
      maxWait="5000"
      username="test"
      url="jdbc:oracle:thin:@10.10.0.1:1901:hccdb"
      maxActive="10"/>
  </GlobalNamingResources>

2、tomcat安装目录\conf\context.xml
     <Resource
      name="jdbc/VoteDB"
      type="javax.sql.DataSource"
      password="test"
      driverClassName="oracle.jdbc.driver.OracleDriver"
      maxIdle="3"
      maxWait="5000"
      username="test"
      url="jdbc:oracle:thin:@10.10.0.1:1901:hccdb"
      maxActive="10"/>

3、spring 的applicationContext.xml

<bean id="myDateSourece" class="org.springframework.jndi.JndiObjectFactoryBean">  
  <property name="jndiName">  
   <value>java:comp/env/jdbc/VoteDB</value>  
  </property>  
  <property name="lookupOnStartup" value="false"/>
     <property name="cache"  value="true"/>
     <property name="proxyInterface"  value="javax.sql.DataSource"/>  
 </bean>

posted on 2008-01-21 11:51 龚椿深 阅读(1321) 评论(0)  编辑  收藏


只有注册用户登录后才能发表评论。


网站导航: