加入收藏 | 设为首页 | 会员中心 | 我要投稿 温州站长网 (https://www.52wenzhou.com/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 编程要点 > 语言 > 正文

在Tomcat服务器下操控连接池连接Oracle数据库

发布时间:2021-12-26 12:12:14 所属栏目:语言 来源:互联网
导读:下面介绍在Tomcat服务器下使用连接池来连接数据库的操作 一:修改web.xml文件: 复制代码 代码如下: ?xml version=1.0 encoding=UTF-8? web-app xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance xmlns=http://java.sun.com/xml/ns/javaee xmlns:web=htt
下面介绍在Tomcat服务器下使用连接池来连接数据库的操作
 
一:修改web.xml文件:
复制代码 代码如下:
 
 
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee " version="3.0">
<display-name>project</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
 
<resource-ref>
<description>DBConnection</description>
<res-ref-name>siniteksirm</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
</web-app>
 
 
在web-app之间插入<resource-ref>这段代码。指定要是用的Resource名称。
 
二:修改tomcat下的context.xml文件:
 
在Context标签之间加入如下代码。
复制代码 代码如下:
 
 
<Resource auth="Container"
type="javax.sql.DataSource"
driverClassName="oracle.jdbc.OracleDriver"
url="jdbc:oracle:thin:@192.168.1.196:1521:orcl"
username="paxt"
password="paxt"
maxActive="20"
maxIdle="10"
maxWait="-1"
testOnBorrow="true"
validationQuery="select 1 from dual"/>
 
 

(编辑:温州站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    热点阅读