在Tomcat服务器下操控连接池连接Oracle数据库
发布时间:2021-12-27 01:54:39 所属栏目:语言 来源:互联网
导读:下面介绍在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"/> (编辑:晋中站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |