zoukankan      html  css  js  c++  java
  • 获取JNDI数据源

    1 在容器中配置数据源

    Tomcat

    <?xml version="1.0" encoding="UTF-8"?>
    <Context>
        <Resource name="jdbc/JavaWeb" auth="Container"
                  type="javax.sql.DataSource"
                  driverClassName="com.mysql.jdbc.Driver"
                  url="jdbc:mysql://localhost:3306/JavaWeb"
                  username="root"
                  password="123456"
                  maxActive="50"
                  maxIdle="30"
                  maxWait="10000" />
    </Context>

    2 Spring中获取数据源

    <jee:jndi-lookup id="dataSource_MySQL_JavaWeb" jndi-name="java:comp/env/jdbc/JavaWeb"/>

    3 web.xml设置数据源

        <!--数据源-->
        <resource-ref>
            <description>MySQL DB Pool</description>
            <res-ref-name>jdbc/JavaWeb</res-ref-name>
            <res-type>javax.sql.DataSource</res-type>
            <res-auth>Container</res-auth>
        </resource-ref>
  • 相关阅读:
    2017.4.6下午
    2017.4.6上午
    2017.3.31下午
    2017.4.5下午
    2017.4.5上午
    2017.4.1上午
    2017.3.31上午
    2017.3.28下午
    2017.3.28上午
    3.28上午
  • 原文地址:https://www.cnblogs.com/sherrykid/p/4623254.html
Copyright © 2011-2022 走看看