tomcat,JDNI配置druid数据源

    1.修改以下节点

<!-- 使用阿里巴巴的DruidDataSource配置针对Oracle数据库的JNDI数据源 -->

    <Resource
        name="jdbc/orcl"
        factory="com.alibaba.druid.pool.DruidDataSourceFactory"
        auth="Container"
        type="javax.sql.DataSource"
        driverClassName="oracle.jdbc.OracleDriver"
        url="jdbc:oracle:thin:@localhost:1521:orcl"
        username="root"
        password="root"
        initialSize="0"    
        maxActive="500"
        maxIdle="100"
        maxWait="10000"
        testOnBorrow="true"
        testWhileIdle="true"
        removeabandoned="true"
        removeabandonedtimeout="60"
        logabandoned="false"
        timeBetweenEvictionRunsMillis="60000"
        minEvictableIdleTimeMillis="300000"
        testOnReturn="false"
        validationQuery="SELECT 'x' FROM DUAL"
        poolPreparedStatements="true"
        maxPoolPreparedStatementPerConnectionSize="20"

        filters="stat"/>  

2.如需要加入的jar包    


3.web.xml配置druid监控

    <!--druid监控-->
  <filter>
    <filter-name>DruidWebStatFilter</filter-name>
    <filter-class>com.alibaba.druid.support.http.WebStatFilter</filter-class>
    <init-param>
      <param-name>exclusions</param-name>
      <param-value>*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid/*</param-value>
    </init-param>
    <init-param>
      <param-name>profileEnable</param-name>
      <param-value>true</param-value>
    </init-param>
  </filter>
  <filter-mapping>
    <filter-name>DruidWebStatFilter</filter-name>
    <url-pattern>/*</url-pattern>
  </filter-mapping>
  <servlet>
    <servlet-name>DruidStatView</servlet-name>
    <servlet-class>com.alibaba.druid.support.http.StatViewServlet</servlet-class>
    <init-param>  
        <!-- 用户名 -->  
        <param-name>loginUsername</param-name>  
        <param-value>root</param-value>  
    </init-param>  
    <init-param>  
        <!-- 密码 -->  
        <param-name>loginPassword</param-name>  
        <param-value>root</param-value>  
    </init-param>    
  </servlet>
  <servlet-mapping>
    <servlet-name>DruidStatView</servlet-name>
    <url-pattern>/druid/*</url-pattern>
  </servlet-mapping>



  

阅读更多
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

不良信息举报

tomcat,JDNI配置druid数据源

最多只允许输入30个字

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭