http://java-source.net/open-source/connection-pools
dbcp와 c3p0 커넥션 풀 유지하기 :: 2009/02/17 18:09
c3p0 - JDBC3 Connection and Statement Pooling
<%@ page language="java" contentType="text/html; charset=EUC-KR" %>
<%@ page import="
java.util.*,
javax.naming.*,
javax.sql.*,
org.apache.commons.beanutils.*,
org.apache.commons.dbcp.*"
%>
<%
Context initContext = new InitialContext();
DataSource ds = (DataSource)initContext.lookup("jdbc/Sims");
BasicDataSource bds = (BasicDataSource)ds;
try {
Map<Object,Object> desc = BeanUtils.describe(bds);
%>
<%=desc%>
<%
} catch(Exception e) {
out.println(e.toString());
}
%>
Race condition error : https://issues.apache.org/jira/browse/DBCP-270
The pool is initialized the first time one of the following methods is invoked: getConnection, setLogwriter, setLoginTimeout, getLoginTimeout, getLogWriter.
http://geroros.hajima.net/entry/iBatis에서-커낵션-에러-날-때
mysql "Communications link failure" 문제
long connection의 경우 의도하지 않은 connection close 현상 발생 가능
|
<bean id="masterDs" class="org.apache.commons.dbcp.BasicDataSource" /> ... <property name="removeAbandoned" value="true" /> <property name="removeAbandonedTimeout" value="30" /> ... </bean> |
|
if(abandonedConfig != null && abandonedConfig.getRemoveAbandoned()) connectionPool = new AbandonedObjectPool(null, abandonedConfig); else connectionPool = new GenericObjectPool(); ... dataSource = new PoolingDataSource(connectionPool);
|
|
conn = (Connection)_pool.borrowObject();
|
|
if(config != null && config.getRemoveAbandoned() && getNumIdle() < 2 && getNumActive() > getMaxActive() - 3) removeAbandoned(); … if(pc.getLastUsed() <= timeout && pc.getLastUsed() > 0L) remove.add(pc); … if(config == null || !config.getRemoveAbandoned()) break MISSING_BLOCK_LABEL_54; synchronized(trace) { boolean foundObject = trace.remove(obj);
|
http://javatech.org/2007/11/c3p0-vs-dbcp-the-straight-dope/