zoukankan      html  css  js  c++  java
  • tomcat中配置JNDI方法

    1、项目中spring的数据源配置:

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

    2、项目中web.xml中的配置

        <resource-ref>
            <res-ref-name>jdbc/test</res-ref-name>
            <res-type>javax.sql.DataSource</res-type>
            <res-auth>Container</res-auth>
            <res-sharing-scope>Shareable</res-sharing-scope>
        </resource-ref>

    3、tomcat中tomcatconfserver.xml中的配置

    
    
      <GlobalNamingResources>
        <!-- Editable user database that can also be used by
             UserDatabaseRealm to authenticate users
        -->
        <Resource auth="Container" description="User database that can be updated and saved" factory="org.apache.catalina.users.MemoryUserDatabaseFactory" name="UserDatabase" pathname="conf/tomcat-users.xml" type="org.apache.catalina.UserDatabase"/>
        <Resource name="jdbc/test" auth="Container" type="javax.sql.DataSource"
                                   url="jdbc:oracle:thin:@192.168.2.123:1521:orcl"
                               driverClassName="oracle.jdbc.driver.OracleDriver"
                               password="test123"
                               username="testname"
                               initialSize="5"
                               maxActive="10"
                               maxIdle="5"
                               minIdle="2"
                               maxWait="10000"
                               removeAbandoned="true"
                               logAbandoned="true"
                               removeAbandonedTimeout="60"
                               timeBetweenEvictionRunsMillis="900000"
                               minEvictableIdleTimeMillis="1800000"
                               numTestsPerEvictionRun="100"
                               validationQuery="select count(0) from dual"
                               poolPreparedStatements="true"
                               maxOpenPreparedStatements="100"/>
         
      </GlobalNamingResources>
     
    4、context.xml中的配置
    <ResourceLink global="jdbc/test" name="jdbc/test" type="javax.sql.DataSource"/>
    
    

    配置完成

     
  • 相关阅读:
    HDOJ骨头的诱惑
    DP Big Event in HDU
    hoj1078
    poj2728
    hoj1195
    poj2739
    poj2726
    海量并发也没那么可怕,运维准点下班全靠它!
    云上安全工作乱如麻,等保2.0来一下
    实践案例丨教你一键构建部署发布前端和Node.js服务
  • 原文地址:https://www.cnblogs.com/shaohz2014/p/6813769.html
Copyright © 2011-2022 走看看