- 浏览: 125091 次
- 性别:
- 来自: 北京
文章分类
最新评论
-
JimmyLincole:
也遇到了类似的问题,感谢;不过解决方法看得不是很明白
spring事务管理UnexpectedRollbackException -
7先生:
你好,请问一下,如果接口参数是一个类,那么如何传递?publi ...
java client调用BlazeDS服务 -
weipeng1986:
很好。能不能说说你怎么分析出的,或者结合源代码讲讲,或者透露下 ...
spring事务管理UnexpectedRollbackException -
cry615:
...
spring事务管理UnexpectedRollbackException -
lotnhiro:
不错 学习了
svn常用命令与分支操作
testOnBorrow默认为true, 要设置为false. 若设置validationQuery则对性能影响比较大.
testWhileIdle默认为false,设置为true.并设置validationQuery
maxIdle最好设置为与maxActive一样。
initialSize与minIdle按业务要求配置,一般都要配置。
timeBetweenEvictionRunsMillis默认为-1.设置一定数值300000
numTestsPerEvictionRun默认是3, 这个值要调大点maxActive的一半较好。
以下apache dbcp的配置项
Parameters
username | The connection username to be passed to our JDBC driver to establish a connection. |
password | The connection password to be passed to our JDBC driver to establish a connection. |
url | The connection URL to be passed to our JDBC driver to establish a connection. |
driverClassName | The fully qualified Java class name of the JDBC driver to be used. |
connectionProperties | The connection properties that will be sent to our JDBC driver when establishing new connections. Format of the string must be [propertyName=property;]* NOTE - The "user" and "password" properties will be passed explicitly, so they do not need to be included here. |
defaultAutoCommit | true | The default auto-commit state of connections created by this pool. |
defaultReadOnly | driver default | The default read-only state of connections created by this pool. If not set then the setReadOnly method will not be called. (Some drivers don't support read only mode, ex: Informix) |
defaultTransactionIsolation | driver default | The default TransactionIsolation state of connections created by this pool. One of the following: (see javadoc)
|
defaultCatalog | The default catalog of connections created by this pool. |
initialSize | 0 | The initial number of connections that are created when the pool is started. Since: 1.2 |
maxActive | 8 | The maximum number of active connections that can be allocated from this pool at the same time, or negative for no limit. |
maxIdle | 8 | The maximum number of connections that can remain idle in the pool, without extra ones being released, or negative for no limit. |
minIdle | 0 | The minimum number of connections that can remain idle in the pool, without extra ones being created, or zero to create none. |
maxWait | indefinitely | The maximum number of milliseconds that the pool will wait (when there are no available connections) for a connection to be returned before throwing an exception, or -1 to wait indefinitely. |
NOTE: If maxIdle is set too low on heavily loaded systems it is possible you will see connections being closed and almost immediately new connections being opened. This is a result of the active threads momentarily closing connections faster than they are opening them, causing the number of idle connections to rise above maxIdle. The best value for maxIdle for heavily loaded system will vary but the default is a good starting point.
validationQuery | The SQL query that will be used to validate connections from this pool before returning them to the caller. If specified, this query MUST be an SQL SELECT statement that returns at least one row. | |
testOnBorrow | true | The indication of whether objects will be validated before being borrowed from the pool. If the object fails to validate, it will be dropped from the pool, and we will attempt to borrow another. NOTE - for a true value to have any effect, thevalidationQuery parameter must be set to a non-null string. |
testOnReturn | false | The indication of whether objects will be validated before being returned to the pool. NOTE - for a true value to have any effect, thevalidationQuery parameter must be set to a non-null string. |
testWhileIdle | false | The indication of whether objects will be validated by the idle object evictor (if any). If an object fails to validate, it will be dropped from the pool. NOTE - for a true value to have any effect, thevalidationQuery parameter must be set to a non-null string. |
timeBetweenEvictionRunsMillis | -1 | The number of milliseconds to sleep between runs of the idle object evictor thread. When non-positive, no idle object evictor thread will be run. |
numTestsPerEvictionRun | 3 | The number of objects to examine during each run of the idle object evictor thread (if any). |
minEvictableIdleTimeMillis | 1000 * 60 * 30 | The minimum amount of time an object may sit idle in the pool before it is eligable for eviction by the idle object evictor (if any). |
connectionInitSqls NOTE: Versions 1.3 and 1.4 of DBCP incorrectly use "initConnectionSqls" as the name of this property for JNDI object factory configuration. Until 1.3.1/1.4.1 are released, "initConnectionSqls" must be used as the name for this property when using BasicDataSoureFactory to create BasicDataSource instances via JNDI. |
null | A Collection of SQL statements that will be used to initialize physical connections when they are first created. These statements are executed only once - when the configured connection factory creates the connection. |
poolPreparedStatements | false | Enable prepared statement pooling for this pool. |
maxOpenPreparedStatements | unlimited | The maximum number of open statements that can be allocated from the statement pool at the same time, or zero for no limit. |
This component has also the ability to pool PreparedStatements. When enabled a statement pool will be created for each Connection and PreparedStatements created by one of the following methods will be pooled:
- public PreparedStatement prepareStatement(String sql)
- public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency)
NOTE - Make sure your connection has some resources left for the other statements. Pooling PreparedStatements may keep their cursors open in the database, causing a connection to run out of cursors, especially if maxOpenPreparedStatements is left at the default (unlimited) and an application opens a large number of different PreparedStatements per connection. To avoid this problem, maxOpenPreparedStatements should be set to a value less than the maximum number of cursors that can be open on a Connection.
accessToUnderlyingConnectionAllowed | false | Controls if the PoolGuard allows access to the underlying connection. |
When allowed you can access the underlying connection using the following construct:
Connection conn = ds.getConnection(); Connection dconn = ((DelegatingConnection) conn).getInnermostDelegate(); ... conn.close()
Default is false, it is a potential dangerous operation and misbehaving programs can do harmfull things. (closing the underlying or continue using it when the guarded connection is already closed) Be carefull and only use when you need direct access to driver specific extentions.
NOTE: Do not close the underlying connection, only the original one.
removeAbandoned | false | Flag to remove abandoned connections if they exceed the removeAbandonedTimout. If set to true a connection is considered abandoned and eligible for removal if it has been idle longer than the removeAbandonedTimeout. Setting this to true can recover db connections from poorly written applications which fail to close a connection. |
removeAbandonedTimeout | 300 | Timeout in seconds before an abandoned connection can be removed. |
logAbandoned | false | Flag to log stack traces for application code which abandoned a Statement or Connection. Logging of abandoned Statements and Connections adds overhead for every Connection open or new Statement because a stack trace has to be generated. |
If you have enabled "removeAbandoned" then it is possible that a connection is reclaimed by the pool because it is considered to be abandoned. This mechanism is triggered when (getNumIdle() < 2) and (getNumActive() > getMaxActive() - 3)
For example maxActive=20 and 18 active connections and 1 idle connection would trigger the "removeAbandoned". But only the active connections that aren't used for more then "removeAbandonedTimeout" seconds are removed, default (300 sec). Traversing a resultset doesn't count as being used.
发表评论
-
【转】git基本命令与使用流程
2011-03-17 21:27 27721 获得帮助可以使用类似man git-****的命令格式: ... -
registered the JBDC driver [com.mysql.jdbc.Driver] but failed to unregister
2011-01-19 18:49 17277异常如下: 严重: The web application [ ... -
svn常用命令与分支操作
2010-11-30 21:29 2148svn基本使用 1. 创建版本库: Svnadmin cre ... -
apache lucene 结构和主要的类
2010-11-08 00:37 1553Apache lucene提供的功能大体可以看作是给一些资料建 ... -
java内存结构与模型
2010-11-04 23:15 1402一、 java内存结构 ... -
java异常处理
2010-11-03 23:04 939一、异常的类结构 Throwable Error: ... -
java client调用BlazeDS服务
2010-03-13 18:20 3375若想直接用java来访问BlazeDS后台的服务,可以用Bla ... -
json lib处理json与java之间转换
2010-01-28 23:36 7944通常采用json-lib来处理java与json之间的转换。 ... -
apache mina ERROR DEAD LOCK: IoFuture.await()
2010-01-13 18:12 3800今天用apache mina简单写一个消息服务时在客户端log ... -
spring事务管理UnexpectedRollbackException
2009-12-17 19:50 26658在使用spring事务管理时 ... -
java中国际化Locale, ResourceBundle
2009-12-16 11:56 1595Java中的与国际化密切相关的类是Locale. 它是国家语言 ... -
static泛型方法
2009-12-10 13:05 3656今天写一个static泛型方法,在本地eclipse没有问题, ...
相关推荐
配置文件中包含了所有必要的属性设定,比如数据库URL、用户名、密码以及连接池的配置选项。 ### DBCP的主要配置项 1. **maxActive**:最大活动连接数,当连接池达到这个数目后,如果还有应用请求连接,会等待直到...
### DBCP配置说明 DBCP(Database Connection Pool)是Apache的一个开源项目,它提供了一种高效的数据库连接池管理方式,能够显著提高基于JDBC的应用程序性能。在使用DBCP时,合理设置其配置参数至关重要,这不仅能...
以下是一些关键的配置选项及其含义: 1. **username** 和 **password**:这两个参数分别用于提供连接数据库所需的用户名和密码,它们会传递给JDBC驱动。 2. **url**:这是一个JDBC URL,用于指示连接哪个数据库...
这两种连接池都能有效地管理和控制数据库连接的创建、分配、回收等过程,并支持多种配置选项来满足不同应用场景的需求。 #### 二、异常问题分析 根据提供的部分内容,“java.sql.SQLException: Already closed.”...
6. **性能优化**:DBCP提供了一些高级配置选项,比如最大连接数(maxActive)、最小空闲连接数(minIdle)、最大等待时间(maxWait)等,可以根据实际应用的负载情况进行调整,以达到最佳的性能和资源利用率。...
例如,从1.3到1.5,可能包含了错误修复、性能提升和新的配置选项。 5. **集成应用**:学习如何将DBCP集成到常见的Web应用服务器如Tomcat或Jetty中,以及如何与Spring框架等进行集成。 6. **异常处理**:了解在使用...
### DBCP优化配置详解 #### 一、DBCP简介 DBCP(Database Connection Pool)是一种数据库连接池技术,主要用于管理数据库连接资源,提高应用程序访问数据库的效率和性能。通过预建立并维护一定数量的数据库连接,...
DBCP适合简单的应用,c3p0提供了更丰富的配置选项,而Druid则以其强大的监控和优化能力受到青睐。在实际应用中,开发者可以根据项目的具体需求和技术栈来决定使用哪种连接池。 在配置数据库连接池时,开发者需要...
它支持基本的配置选项,例如最大连接数、最小空闲连接数、超时设置等。`BasicDataSource`还实现了`javax.sql.DataSource`接口,使得它能够与Java的JDBC API无缝集成。 `commons-logging-1.1.1-1.0.0.jar`是Apache ...
4. **配置灵活**:DBCP提供了丰富的配置选项,可以根据实际需求调整连接池的大小、超时时间、验证策略等参数。 5. **异常处理**:当池中的连接耗尽时,DBCP可以抛出异常,提示开发者适时增加连接池大小。 使用DBCP...
此外,DBCP还提供了连接池的配置选项,如最大连接数、最小连接数、超时时间等,以便根据应用需求进行调整。 2. **commons-pool.jar**:Apache Commons Pool是DBCP用来管理对象池的库,包括数据库连接池。DBCP依赖于...
Apache Commons DBCP,全称为"Database Connection Pool",是Apache软件基金会开发的一个开源项目,主要...虽然现代的连接池解决方案如HikariCP和C3P0提供了更好的性能和特性,但DBCP在许多场景下仍是一个可靠的选项。
总的来说,DBCP是一个高效且易用的数据库连接池实现,对于Java应用开发来说,它能够优化数据库访问性能,提升系统效率,同时提供了丰富的配置选项以适应不同的应用场景。在实际使用中,开发者需要根据应用的规模和...
- **重要性**:这些参数可以用来传递特定于数据库的配置选项,如字符集等。 #### 8. `defaultAutoCommit` - **参数描述**:表示通过连接池创建的连接的默认自动提交状态。 - **缺省值**:通常为`true`。 - **重要性...
DBCP连接池提供了许多其他配置选项,如验证查询(用于检查连接是否有效)、连接测试间隔等,可以根据实际需求进行调整。此外,还可以通过设置`poolPreparedStatements`和`maxOpenPreparedStatements`来管理预编译的...
例如,HikariCP以其优秀的性能和低延迟而著名,而C3P0则提供了更丰富的配置选项和更强大的异常处理能力。 总的来说,DBCP作为一款老牌的数据库连接池工具,对于小型项目或者学习使用是足够的,但对于大型、高并发的...
6. 性能优化:DBCP提供了多种性能优化选项,例如预热连接、空闲连接检测、连接有效性检查等,可以根据实际情况调整这些参数。 7. 监控与维护:DBCP提供了监控接口,可以集成到应用的监控系统中,以便于观察连接池的...
Apache DBCP(Database Connection Pool)1.4是Apache软件基金会的一个开源项目,它提供了一个数据库连接池服务,用于管理数据库...通过理解其工作原理和配置选项,开发者可以有效地利用这个工具优化数据库操作的性能。
Apache DBCP(数据库连接池)是Apache软件基金会下的一个开源项目,主要用于提供数据库连接池服务。这个项目包含了几个关键的组件,其中`commons-...开发者在使用时应充分理解其配置选项,以便根据实际需求进行优化。
然而,对于一些旧项目或对性能要求不高的应用,DBCP仍是一个可靠的选项。 总的来说,DBCP连接池是Java应用程序中用于高效管理数据库连接的重要工具,通过合理的配置和使用,可以显著提升系统运行效率。