tomcat6数据库连接池配置
来源:互联网 发布:有哪些网络倾听者平台 编辑:程序博客网 时间:2024/04/29 21:00
1.将相应的数据库jar驱动放到tomcat/lib目录下
2.打开tomcat/conf/context.xml添加如下代码
< resource name=" jdbc/sample"
auth=" container"
type=" javax.sql.datasource"
driverclassname=" com.jnetdirect.jsql.jsqldriver"
url=" jdbc:jsqlconnect://localhost:1433/database=ebibi"
username=" ebibi"
password=" ebibi"
maxactive=" 100"
maxidle=" 30"
maxwait=" 10000" />
name:数据库池名如" jdbc/sample" 、" oracle" ....
auth:是指定管理resource的manager 有application 和container 两个选项.container表示由容器创建
type:指定resource所属的java类名
driverclassname:驱动名
url:数据库的链接地址
username:数据库用户名
username:数据库密码
maxactive:指定数据库中连接池中处于活动状态的数据连接的最大数目 取值为0表示不受限制.
maxidle:指定数据库中连接池中处于空闲状态的数据连接的最大数目
maxwait:最大等待数
链接驱动
(1)sqlserver
jsqlconnect.jar 链接sqlserver的驱动
driverclassname=" com.jnetdirect.jsql.jsqldriver"
url=" jdbc:jsqlconnect://localhost:1433/database=ebibi"
(2)oracle
classes12.jar 链接oracle9、的驱动
ojdbc6.jar 链接oracle11g的驱动
driverclassname=" oracle.jdbc.driver.oracledriver"
url=" jdbc:oracle:thin: locahost:1521:oracle"
3.在web程序的web—inf/web.xml中增加以下配置
< resource-ref>
< description> db connection< /description>
< res-ref-name> jdbc/sample< /res-ref-name>
< res-type> javax.sql.datasource< /res-type>
< res-auth> container< /res-auth>
< /resource-ref>
description:描述
res-ref-name:数据库链接池名
res-type:resource所属的java类名
res-auth:resource的manager 有application 和container 两个选项.container表示由容器创建
4.servlet或jsp代码
导入包javax.naming.context javax.sql.datasource java.sql.connection
//获得上下文
context context = new initialcontext()
//获得数据源
datasource ds = (datasource)context.lookup(" java:comp/env/jdbc/sample" )
//获取连接
connection conn = ds.getconnection()
- tomcat6数据库连接池配置
- tomcat6数据库连接池配置
- Tomcat6 数据库连接池配置
- Tomcat6数据库连接池配置
- tomcat6数据库连接池配置
- tomcat6配置oracle数据库连接池
- tomcat6数据库连接池的配置
- Tomcat6数据库连接池的配置
- Tomcat6.0配置数据库连接池
- TomCat6.0数据库连接池配置
- TomCat6.0数据库连接池配置
- Tomcat6.0数据库连接池配置
- Tomcat6.0数据库连接池配置
- Tomcat6配置数据库连接池 And 虚拟目录
- tomcat6.0 + JSP + mysql数据库连接池配置
- tomcat6.0 + JSP + mysql数据库连接池配置
- tomcat6.0中配置数据库连接池
- Tomcat6数据库连接池配置(context.xml)
- win 远程拷贝文件 bat 批处理
- JAVA调用存储过程
- ASP.NET教程;一个合格的皮肤机制体系的实现
- UML符号简介
- JAVA正则表达式 Pattern和Matcher 详细出处参考:http://www.jb51.net/article/17943.htm
- tomcat6数据库连接池配置
- div中文字垂直居中
- hello world
- SQLServer 参数化查询经验分享
- 数据库设计之范式
- 伯乐在线
- 初次見面 請多指教
- 引用 Admin5对话个性网王小峰:用户需求的才是最好的
- Dalvik线程模型