jdbc

Edit

참조하는 jar파일 확인

pmap [pid] | grep jar

혹은 cat /proc/<pid>/smaps

ps axuw | grep java | grep -v grep | awk '{print $2}' | while read P; do pmap $P | grep 'spring' ; done

Statement Cache

Connection pool

모니터링

<%@ 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());
 }
%>

DBCP

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.

testOnBorrow

removeAbandoned

<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);

성능비교

JDBC API 사용법

Statment를 안 가지면 maximum open cursor exceed ! 에러나 Limit on number of statements exceeded 에러 발생

각종 DBMS JDBC 드라이버 셋팅법 정리

에러 관련

Mysql

Fetch size

autoreconnect=true

Mysql batchupdate

BLOB image 관련

기타

Children