Apache DBCP BasicDataSource Configuration Parameters
来源:互联网 发布:温雅婷事件 知乎 编辑:程序博客网 时间:2024/04/29 21:03
BasicDataSource Configuration Parameters
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.
- NONE
- READ_COMMITTED
- READ_UNCOMMITTED
- REPEATABLE_READ
- SERIALIZABLE
Since: 1.2maxTotal8The maximum number of active connections that can be allocated from this pool at the same time, or negative for no limit.maxIdle8The maximum number of connections that can remain idle in the pool, without extra ones being released, or negative for no limit.minIdle0The minimum number of connections that can remain idle in the pool, without extra ones being created, or zero to create none.maxWaitMillisindefinitelyThe 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.
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.
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 harmful things. (closing the underlying or continue using it when the guarded connection is already closed) Be careful and only use when you need direct access to driver specific extensions.
NOTE: Do not close the underlying connection, only the original one.
removeAbandonedOnBorrowfalseFlags to remove abandoned connections if they exceed the removeAbandonedTimout.
A connection is considered abandoned and eligible for removal if it has not been used for longer than removeAbandonedTimeout.
Creating a Statement, PreparedStatement or CallableStatement or using one of these to execute a query (using one of the execute methods) resets the lastUsed property of the parent connection.
Setting one or both of these to true can recover db connections from poorly written applications which fail to close connections.
Setting removeAbandonedOnMaintenance to true removes abandoned connections on the maintenance cycle (when eviction ends). This property has no effect unless maintenance is enabled by setting timeBetweenEvicionRunsMillis to a positive value.
If removeAbandonedOnBorrow is true, abandoned connections are removed each time a connection is borrowed from the pool, with the additional requirements that
- getNumActive() > getMaxTotal() - 3; and
- getNumIdle() < 2
Logging of abandoned Statements and Connections adds overhead for every Connection open or new Statement because a stack trace has to be generated.abandonedUsageTrackingfalseIf true, the connection pool records a stack trace every time a method is called on a pooled connection and retains the most recent stack trace to aid debugging of abandoned connections. There is significant overhead added by setting this to true.
If you have enabled removeAbandonedOnMaintenance or removeAbandonedOnBorrow 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() > getMaxTotal() - 3) and removeAbandonedOnBorrow is true; or after eviction finishes and removeAbandonedOnMaintenance is true. For example, maxTotal=20 and 18 active connections and 1 idle connection would trigger removeAbandonedOnBorrow, 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. Creating a Statement, PreparedStatement or CallableStatement or using one of these to execute a query (using one of the execute methods) resets the lastUsed property of the parent connection.
The SQL_STATE codes considered to signal fatal errors are by default the following:
- 57P01 (ADMIN SHUTDOWN)
- 57P02 (CRASH SHUTDOWN)
- 57P03 (CANNOT CONNECT NOW)
- 01002 (SQL92 disconnect error)
- JZ0C0 (Sybase disconnect error)
- JZ0C1 (Sybase disconnect error)
- Any SQL_STATE code that starts with "08"
- Apache DBCP BasicDataSource Configuration Parameters
- apache dbcp basicdatasource validator
- Struts2 org.apache.commons.dbcp.BasicDataSource
- org.apache.commons.dbcp.BasicDataSource 设置技巧
- org.apache.commons.dbcp.BasicDataSource 资源包下载
- 日记:Cannot find class [org.apache.commons.dbcp.BasicDataSource]问题
- application.xml "org.apache.commons.dbcp.BasicDataSource] not found "
- class"org.apache.commons.dbcp.BasicDataSource"not found解决方案
- java.lang.ClassNotFoundException: org.apache.commons.dbcp.BasicDataSource的解决方法
- 找不到"org.apache.commons.dbcp.BasicDataSource"的解决方法
- class"org.apache.commons.dbcp.BasicDataSource"not found解决方案
- Cannot find class [org.apache.commons.dbcp.BasicDataSource
- Cannot find class [org.apache.commons.dbcp.BasicDataSource]出异常
- Class 'org.apache.commons.dbcp.BasicDataSource' not found
- 对于org.apache.commons.dbcp.BasicDataSource的配置认知
- Cannot find class [org.apache.commons.dbcp.BasicDataSource]
- org.apache.commons.dbcp.BasicDataSource连接池配备属性
- org.apache.commons.dbcp.BasicDataSource连接池配备属性
- FRM笔记之金融市场与产品-关于利率
- HttpClient4.5.2调用示例(转载+原创)
- git merge 和 git rebase 小结
- Android 配合Jenkins使用Gradle脚本命令打包上传到蒲公英
- 几种常用的ios 面试题
- Apache DBCP BasicDataSource Configuration Parameters
- QT相关的资源总结
- Shell Programming in 24 hours (上)
- 需求人员使用CQ的基本职责
- 温故而知新——JavaSE基础
- Web网站的几个QPS
- 分布式消息系统Kafka初步
- 用Recyclerview实现列表分组、下拉刷新以及上拉加载--源码
- ZigBee简介