Tomcat 7 JDBC Connection Pool
来源:互联网 发布:ajax发送json数据 编辑:程序博客网 时间:2024/06/05 10:47
原文:http://ramonblog.cloudfoundry.com/blog/4fd34be35e8e781871000001
commons-dbcp
Before introduce tomcat 7 jdbc connection pool, we have a basic and simple introduction aboutcommons-dbcp. To use dbcp, as below steps:
- download dbcp from here and its dependency commons-pool.
- put those two libs into WEB-INF/lib
- You can use BasicDataSource as these sample code Note: use jdbc directly, it's boring and tedious. I suggest use spring jdbc template.
Tomcat Built in Connection Pool
Tomcat provides a replacement or alternative for commons-dbcp since version 6. Old connection pool is also based commons-dbcp. You can find detail information about tomcat new connection pool from here: The Tomcat JDBC Connection Pool. From that we know, it's much better than commons-dbcp.
To use it, we need do below things. For detail see The Tomcat JDBC Connection Pool. 1. put jdbc driver into {catalina}/lib. Usually we put jdbc library into WEB-INF/lib as app library. Because we need add resource in context which is initialized by tomcat, not considering your apps library in WEB-INF/lib. Therefore it would throw exception 'cannot find jdbc driver' when tomcat startup. 2. configure resource in context.xml. You can find detail information from here, note you can find more information about Context from here. In my app, I add context.xml in META-INF 3. configure resource ref in web.xml 4. get resource from java code.
Note for step 2, you need set password/username/url to make sure connect to database. If your app need read it from other configuration, such as Amazon Beanstalk read connection from Container parameter, you cannot use JNDI to find pool settings, just use programatic way PoolProperties likehere
Connection pool in Amazon Beanstalk
To use tomcat built in connection pool, we need put jdbc driver into {catalina}/lib. To do that, we need customize our environment, see here. Therefore it's better use commons-dbcp for your simple application.
- Tomcat 7 JDBC Connection Pool
- Java模块 -- Tomcat JDBC Connection pool
- JDBC Connection Pool
- JDBC Connection Pool --> Monitoring
- tomcat connection pool jndi
- Tomcat 7连接池--Tomcat jdbc pool
- Spring + jdbc +connection pool + transaction
- Could not get JDBC Connection; nested exception is org.apache.tomcat.jdbc.pool.PoolExhaustedExceptio
- Tomcat JDBC Pool初探
- tomcat jdbc pool 配置
- tomcat jdbc-pool
- tomcat connection pool(mysql)
- JNDI、JDBC、Connection Pool的关系
- JDBC----数据库连接池(connection pool)
- tomcat jdbc-pool 的使用
- Spring - Tomcat jdbc pool 配置
- Tomcat-Jdbc-Pool参数说明
- [Tomcat]Cannot get a connection, pool exhausted
- 二、基本算法之DFS、BFS和A*
- Selenium 环境配置
- Windwos远程执行Linux命令
- 到了对学习赖宁活动进行小结的时候了
- gdb常用调试命令
- Tomcat 7 JDBC Connection Pool
- No 139 · float,double和decimal类型
- Super Pig游戏开发记录(1)
- linux中断机制简单分析
- UBUNTU开启TELNET服务
- nodejs系列之八——nodejs与cloudfoundry
- 运行CMD 查看端口命令及端口功能详解
- Undrer S3C6410, Setting ARM cpu frequency 667MHz.
- SW watchdog 分析