0
我遇到了问题,我的Web应用程序冻结了。使用JConsole监视工具,我发现应用程序正在达到maxPoolSize。这是导致应用程序冻结。由于达到maxPoolSize而导致应用程序冻结
系统上有大约20个用户,每个用户可以有多个网络会话。
下面是应用程序中的HttpServlet示例。
public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
Session sess = null;
Transaction tx = null;
try {
sess = RuntimeContext.getCurrentSession();
tx = sess.beginTransaction();
doingStuffWithSession(req, res, sess);
if (!tx.wasCommitted()) {
tx.commit();
}
} catch (Exception e) {
handleException(e, req, sess);
} finally {
if (sess != null && sess.isOpen() && tx != null && tx.isActive()) {
tx.rollback();
}
}
}
这里是我的休眠特性在C3P0:
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.SQLServerDialect"/>
<property name="hibernate.archive.autodetection" value="class, hbm"/>
<property name="hibernate.c3p0.min_size" value="20" />
<property name="hibernate.c3p0.max_size" value="200" />
<property name="hibernate.c3p0.timeout" value="300" />
<property name="hibernate.c3p0.max_statements" value="50" />
<property name="hibernate.c3p0.idle_test_period" value="3000" />
</properties>