applicationContext.xml
< bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean"> < property name="jndiName">java:comp/env/jdbc/oracleDB< /value> < /property> < /bean>
以下為 tomcat 的設定
context.xml
< ResourceLink global ="jdbc/oracleDB" name ="jdbc/oracleDB" type="javax.sql.DataSource"/>
server.xml
context -> host
方法一
< Resource name="jdbc/oracleDB"
auth="Container"
type="javax.sql.DataSource"
factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"
driverClassName="oracle.jdbc.OracleDriver"
url="jdbc:oracle:thin:@localhost:1521:xe"
username="A17A"
password="a17a"
maxActive="20"
maxIdle="10" />
方法二
< web-app/> 前要加
< ResourceLink global ="jdbc/oracleDB" name ="jdbc/oracleDB" type="javax.sql.DataSource"/>
用此寫法 方法一 要放在 GlobalNamingResources 標籤裡
web.xml
< resource-ref>
< description> Oracle DB< /description>
< res-ref-name>jdbc/oracleDB< /res-ref-name>
< res-type>javax.sql.DataSource< /res-type>
< res-auth>Container< /res-auth>
< /resource-ref>
https://codingboy.pixnet.net/blog/post/43989964
https://confluence.atlassian.com/conf59/configuring-an-oracle-datasource-in-apache-tomcat-792499575.html
https://www.itdaan.com/tw/2adf782563384d906ad58d8a84f4f2ed