我提交的服务3个的时候还很好,但是第四个还有问题,所以我以为是maxIdle的问题,所以我把它的值加到4,然后我也不服务重新启动了,但是到第四个服务的时候,还是不行,其中jboss报错如下: FATAL[XNetworkDAO] SQL EXCEPTION: org apache.commons.dbcp. SQLNestdException Cannot get a connection . pool exhausted ,cause: Timeout waiting for idle object.
能不能从log文件中看出是否访问后没有关闭连接呢。
{
DataSource ds = getDataSource(request, Constants.DATABASE_KEY); if (ds!=null) {
Connection conn = ds.getConnection();
if (conn!=null) {
UserDAO userDAO = new UserDAO(conn);
return userDAO;
}
}
return null;
}
private void setupUserList(HttpServletRequest request) throws Exception {
HttpSession session = request.getSession();
DataSource ds = getDataSource(request, Constants.DATABASE_KEY); if (ds==null) {
log.info("Could not find DataSource");
}
else {
Connection conn = ds.getConnection();
if (conn!=null) {
ArrayList userList;
UserDAO userInfo = new UserDAO(conn);
String menuRight =(String)session.getAttribute("menu140");
int menu_140_dom = Integer.parseInt(menuRight);
if(menu_140_dom == 4 || menu_140_dom == 6){
userList = userInfo.loadUserList();
log.info("UserList size=" + userList.size());
}
else /*if(menu_140_dom == 0)*/{
AuthToken userinfo = (AuthToken)session.getAttribute(Constants.AUTH_KEY);
int myselfid= userinfo.getId();
userList = userInfo.loadUserList(myselfid);
log.info("UserList size=" + userList.size()); } if (userList!=null)
session.setAttribute(Constants.USERLIST_KEY, userList);
conn.close();
}
}
}
FATAL[XNetworkDAO] SQL EXCEPTION: org apache.commons.dbcp. SQLNestdException Cannot get a connection . pool exhausted ,cause: Timeout waiting for idle object.
<set-property property="removeAbandonedTimeout" value="60"/>改成
<set-property property="removeAbandonedTimeout" value="25"/>
就可以了,但我不是很明白是为什么呢!感觉程序里面还可能有问题(因为心里没底)