jndi data source configuration

In web.xml:

<!-- 加载jndi -->
  <resource-ref>
        <description>DB Connection</description>
        <res-ref-name>jdbc/ORAC</res-ref-name>
        <res-type>javax.sql.DataSource</res-type>
        <res-auth>Container</res-auth>
    </resource-ref>

 

the context.xml in tomcat:  

Add internal connection pool configuration context tags: where name is

<Resource name="jdbc/ORAC" auth="Container" type="javax.sql.DataSource" maxActive="100" maxIdle="30" maxWait="10000" username="888888" password="888888" driverClassName="oracle.jdbc.driver.OracleDriver" url="jdbc:oracle:thin:@192.168.0.180:1521:****"/> 上边xml中配置的name

 

In application.xml:

    <-! Jndi Related ->
    <the bean ID = "the dataSource" class = "org.springframework.jndi.JndiObjectFactoryBean">
        <Property name = "The jndiName">
            <value> Java: CoMP / the env / JDBC / the ORAC < / value>
        </ Property>
    </ bean>
    <-! the Spring and MyBatis perfect integration, no mybatis configuration mapping files ->
    <bean the above mentioned id = "SqlSessionFactory" class = "org.mybatis.spring.SqlSessionFactoryBean">
        <Property name = "dataSource" ref = "dataSource" />
        <-! mapping.xml automatically scan the file ->
        <Property name = "mapperLocations">
            <List>
                <value> the CLASSPATH: Mapper / *.xml</value>
            </list>
        </property>
    </bean>
    <!-- 使用JDBC事物 -->
    <bean id="transactionManager"
        class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
        <property name="dataSource" ref="dataSource" />
    </bean>
    <!-- jndi相关配置结束 -->

Published 66 original articles · won praise 8 · views 130 000 +

Guess you like

Origin blog.csdn.net/qq_37889636/article/details/85114036