站长网 语言 在Tomcat服务器下操控连接池连接Oracle数据库

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

下面介绍在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=h

下面介绍在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"/>
 
 

本文来自网络,不代表站长网立场,转载请注明出处:https://www.tzzz.com.cn/html/biancheng/yuyan/2021/1226/43194.html

作者: dawei

【声明】:站长网内容转载自互联网,其相关言论仅代表作者个人观点绝非权威,不代表本站立场。如您发现内容存在版权问题,请提交相关链接至邮箱:bqsm@foxmail.com,我们将及时予以处理。
联系我们

联系我们

0577-28828765

在线咨询: QQ交谈

邮箱: xwei067@foxmail.com

工作时间:周一至周五,9:00-17:30,节假日休息

返回顶部