tomcat配置数据库连接池步骤详解
来源:互联网 发布:windows 10 输入法切换 编辑:程序博客网 时间:2024/06/02 06:27
1. 首先在tomcat中配置context.xml,把连接数据库的一些参数配置进去,配置如下:
- <Resource
- name="jdbc/books"
- auth="Container"
- type="javax.sql.DataSource"
- maxActive="100"
- maxIdle="30"
- maxWait="10000"
- driverClassName="com.mysql.jdbc.Driver"
- url="jdbc:mysql://localhost:3306/books"
- username="root"
- password="123456"
- />
2. 配置web.xml,把数据库连接池引用到项目中:
- <resource-ref>
- <res-ref-name>jdbc/books</res-ref-name>
- <res-type>javax.sql.DataSource</res-type>
- <res-auth>Container</res-auth>
- </resource-ref>
3. 在数据库操作类中获取连接池的连接:
- Context context = new InitialContext();
- DataSource dataSource = (DataSource)context.lookup("java:comp/env/jdbc/books");
- Connection con =dataSource.getConnection();
以上访问就是设置和获取tomcat配置的连接池了,剩下的就是一下简单的jdbc操作了
0 0
- tomcat配置数据库连接池步骤详解
- tomcat配置数据库连接池步骤详解
- tomcat配置数据库连接池步骤详解
- tomcat配置数据库连接池步骤详解
- tomcat配置数据库连接池步骤详解
- tomcat数据库连接池配置步骤
- 配置数据库连接池步骤
- tomcat配置数据库连接池
- 配置tomcat数据库连接池
- tomcat数据库连接池配置
- tomcat配置数据库连接池
- tomcat 数据库连接池配置
- Tomcat 数据库连接池配置
- tomcat数据库连接池配置!
- tomcat数据库连接池配置
- tomcat数据库连接池配置
- tomcat数据库连接池配置
- Tomcat 配置数据库连接池
- 数据仓库的源数据类型
- jdk5.0 新增的 Concurrent包主要功能详解
- J2EE领域的一些技术框架结构图
- 阻塞的理解
- [Unity-10] Unity脚本的生命周期
- tomcat配置数据库连接池步骤详解
- attachEvent/detachEvent 与 addEventListener/removeEventListener区别
- 【IzPack】简介
- IOS中手势密码界面的实现
- [算法竞赛入门经典] UVA 1471 - Defense Lines
- POJ 2769 Reduced ID Numbers
- 对Java中String对象的值和长度是不变化的理解
- Git 初步
- Hefei Super Electronics Co., Ltd.