내 응용 프로그램이 최대 절전 모드 4.1.7 및 c3p0 0.9.1을 사용 중입니다.설정에서 지정된 것보다 많은 연결을 생성하는 c3p0
내 응용 프로그램의 hibernate.cfg.xml 파일에 c3p0.max_size 속성을 50으로 설정했지만 생성 된 JDBC 연결 수가이 값을 초과했습니다. 또한 휴면/유휴 연결은 Hibernate 구성에서도 지정 했으므로 제거되지 않습니다. 내 구성에서 잘라내 기는 다음과 같습니다.
<property name="c3p0.acquire_increment">1</property>
<property name="c3p0.autoCommitOnClose">false</property>
<property name="c3p0.max_size">50</property>
<property name="c3p0.min_size">1</property>
<property name="c3p0.numHelperThreads">1</property>
<property name="c3p0.maxIdleTime">30</property>
<property name="c3p0.maxIdleTimeExcessConnections">20</property>
<property name="c3p0.maxConnectionAge">45</property>
내 코드에서 finally 블록의 세션과 세션 팩토리를 명시 적으로 닫고 있습니다. 나는 로그를 변경
public static int insert(int aidm, String termCode, String wappCode) throws SQLException, ClassNotFoundException {
// Initialize session and transaction
SessionFactory sessionFactory = HibernateSessionFactory.create();
Session session = sessionFactory.openSession();
Transaction tx = null;
int applSeqno = 0;
Stvwapp wapp = null;
try {
tx = session.beginTransaction();
applSeqno = generateApplSeqNo(session, aidm);
SarheadId sarheadIdDao = new SarheadId();
sarheadIdDao.setSarheadAidm(aidm);
sarheadIdDao.setSarheadApplSeqno((short)applSeqno);
// Find STVWAPP row by WAPP code
Query query = session.getNamedQuery("findStvwappByWappCode");
query.setString("wappCode", wappCode);
if (query.list().size() == 0) {
throw new RuntimeException("Invalid WAPP code specified: " + wappCode);
} else {
wapp = (Stvwapp) query.list().get(0);
}
Sarhead sarheadDao = new Sarhead();
sarheadDao.setId(sarheadIdDao);
sarheadDao.setSarheadActivityDate(new java.sql.Timestamp(System.currentTimeMillis()));
sarheadDao.setSarheadAddDate(new java.sql.Timestamp(System.currentTimeMillis()));
sarheadDao.setSarheadAplsCode("WEB");
sarheadDao.setSarheadApplAcceptInd("N");
sarheadDao.setSarheadApplCompInd("N");
sarheadDao.setSarheadApplStatusInd("N");
sarheadDao.setSarheadPersStatusInd("N");
sarheadDao.setSarheadProcessInd("N");
sarheadDao.setSarheadTermCodeEntry(termCode);
sarheadDao.setStvwapp(wapp);
session.save(sarheadDao);
} finally {
tx.commit();
session.close();
sessionFactory.close();
}
return applSeqno;
}
업데이트 :
package ics.sis.util;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
import org.hibernate.service.ServiceRegistry;
import org.hibernate.service.ServiceRegistryBuilder;
import ics.global.runtime.Environment;
import ics.util.properties.PropertiesISUWrapper;
public class HibernateSessionFactory {
private static SessionFactory sessionFactory;
private static ServiceRegistry serviceRegistry;
private static final PropertiesISUWrapper ISU_PROPERTIES = new PropertiesISUWrapper(Environment.getName(),"VzAppIntegration");
public static SessionFactory create() {
Configuration configuration = new Configuration();
configuration.configure();
configuration.setProperty("hibernate.connection.url", ISU_PROPERTIES.getUrl());
configuration.setProperty("hibernate.connection.password", ISU_PROPERTIES.getPassword());
serviceRegistry = new ServiceRegistryBuilder().applySettings(configuration.getProperties()).buildServiceRegistry();
sessionFactory = configuration.buildSessionFactory(serviceRegistry);
return sessionFactory;
}
}
여기 데이터베이스 트랜잭션을 수행하는 주요 방법 중 하나입니다 : 여기 내 SessionFactory에 인스턴스를 생성하기 위해 사용하고 클래스이다 연결 풀링에 대한 자세한 로깅을 얻으려면 c3p0의 수준을 DEBUG로 설정하고 만료 된 연결마다 3 ~ 4 초마다 확인합니다. 또한, 나는 수영장에 총 두 개의 연결이있는 것처럼 보이는 다음 줄이 기록되는 것을보고있다. 그러나 Toad에서는 열려있는 총 JDBC 연결을 모니터링하고 있으며이를 보여줍니다. 그래서이 숫자 사이에 왜 불일치가 있는지를 파악하려고합니다.
[봉투 : DEVL] [] - 2012년 12월 6일 12시 14분 7초 디버그 BasicResourcePool : 1,644 - 관리 추적 [email protected] [: 1, 미사용 : 1, 제외 : 0] (예 : [email protected])
그게 내가 대답했다. P : P –