1.在tomcat6.0/conf/context.xml加入以下代码
[xhtml] view plain copy
<Resource name="jdbc/oracleDB" auth="Container" type="javax.sql.DataSource"
driverClassName="oracle.jdbc.driver.OracleDriver"
username="***" password="**"
url="jdbc:oracle:thin:@192.168.*.*:1521:test"
maxActive="50" maxIdle="10" maxWait="20000" initialSize="5"
/>
2.在项目的配置文件中applicationContext.xml文件中加入以下代码:
[xhtml] view plain copy
<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName">
<value>java:comp/env/jdbc/oracleDB</value>
</property>
</bean>
3.在web.xml文件中加入以下代码
[xhtml] view plain copy
<resource-ref>
<res-ref-name>jdbc/oracleDB</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
[xhtml] view plain copy
<Resource name="jdbc/oracleDB" auth="Container" type="javax.sql.DataSource"
driverClassName="oracle.jdbc.driver.OracleDriver"
username="***" password="**"
url="jdbc:oracle:thin:@192.168.*.*:1521:test"
maxActive="50" maxIdle="10" maxWait="20000" initialSize="5"
/>
2.在项目的配置文件中applicationContext.xml文件中加入以下代码:
[xhtml] view plain copy
<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName">
<value>java:comp/env/jdbc/oracleDB</value>
</property>
</bean>
3.在web.xml文件中加入以下代码
[xhtml] view plain copy
<resource-ref>
<res-ref-name>jdbc/oracleDB</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
本文介绍如何在Tomcat服务器中配置Oracle数据库的数据源,并详细展示了在context.xml、applicationContext.xml及web.xml文件中需要添加的具体配置代码。
852

被折叠的 条评论
为什么被折叠?



