读书人

java网站关于jdbc连接池的有关问题报

发布时间: 2013-09-17 13:35:59 作者: rapoo

java网站,关于jdbc连接池的问题报错,紧急,请大神指点!!!解决不了又要被老板骂了。
[align=center]项目启动后按F5一直刷新网站主页,
1.刚开始刷新后异常的信息为:java.sql.SQLException: We are already in the process of making 11 connections and the number of simultaneous builds has been throttled to 10

2.刷新一段时候后异常的信息为:java.sql.SQLException: Couldn't get connection because we are at maximum connection count (200/200) and there are none

3.最后报内存溢出异常。[/align]
代码我检查了没问题,pst,rs,conn该关闭的都关闭了,访问主页的19个查询方法也是平级的概念。

@RequestMapping(value = { "indexInfo" }, method = { RequestMethod.GET,
RequestMethod.POST })
public ModelAndView indexInfo(HttpServletRequest request,
HttpServletResponse response, HttpSession session, ModelMap modelMap)
throws Exception {

List<Map<String, Object>> maps = browseByPicNewsType(7);

StringBuffer sb = new StringBuffer();
StringBuffer sb1 = new StringBuffer();
StringBuffer sb2 = new StringBuffer();
for (Map<String, Object> map : maps) {
sb.append("../");
sb.append(map.get("IMAGEPATH"));
sb.append("|");

sb1.append("../news_pic/picInfo.do?id=");
sb1.append(map.get("ID"));
sb1.append("|");

sb2.append(map.get("TITLE"));
sb2.append("|");
}

modelMap.put("news_pic_imgpath", sb.substring(0, sb.length() - 1));
modelMap.put("news_pic_url", sb1.substring(0, sb1.length() - 1));
modelMap.put("news_pic_title", sb2.substring(0, sb2.length() - 1));

objList = new ArrayList();
HashMap optionMap = new HashMap();
optionMap.put("value", "content");
optionMap.put("text", "文章");
objList.add(optionMap);

optionMap = new HashMap();
optionMap.put("value", "pics");
optionMap.put("text", "图片");
objList.add(optionMap);

// 经信动态
List<Map<String, Object>> jingxindongtai = getAdminService()
.select(
" jxw_news",
"Id, title, content,newType,userName,hints, issueDate,createdate",
"newType=9 order by createdate desc limit 0,9");
modelMap.put("jingxindongtai", jingxindongtai);

// 领导讲话
List<Map<String, Object>> lingdaojianghua = getAdminService()


.select(
" jxw_news",
"Id, title, content,newType,userName,hints, issueDate,createdate",
"newType=4 order by createdate desc limit 0,10");
modelMap.put("lingdaojianghua", lingdaojianghua);

// 政策文件
List<Map<String, Object>> zhengcewenjian = getAdminService()
.select(
" jxw_news",
"Id, title, content,newType,userName,hints, issueDate,createdate",
"newType=10 order by createdate desc limit 0,10");
modelMap.put("zhengcewenjian", zhengcewenjian);

// 机关党建
List<Map<String, Object>> jiguandangjian = getAdminService()
.select(
" jxw_news",
"Id, title, content,newType,userName,hints, issueDate,createdate",
"newType=37 order by createdate desc limit 0,10");
modelMap.put("jiguandangjian", jiguandangjian);

// 县区工作
List<Map<String, Object>> xianqugongzuo = getAdminService()
.select(
" jxw_news",
"Id, title, content,newType,userName,hints, issueDate,createdate",
"newType=40 order by createdate desc limit 0,10");
modelMap.put("xianqugongzuo", xianqugongzuo);

// 综合信息
List<Map<String, Object>> zonghexinxi = getAdminService()
.select(
" jxw_news",
"Id, title, content,newType,userName,hints, issueDate,createdate",
"newType=2 order by createdate desc limit 0,10");
modelMap.put("zonghexinxi", zonghexinxi);

// 经信知识
List<Map<String, Object>> jingxinzhishi = getAdminService()
.select(
" jxw_news",
"Id, title, content,newType,userName,hints, issueDate,createdate",
"newType=64 order by createdate desc limit 0,10");
modelMap.put("jingxinzhishi", jingxinzhishi);

// 政策法规
List<Map<String, Object>> zhengcefagui = getAdminService()
.select(
" jxw_news",
"Id, title, content,newType,userName,hints, issueDate,createdate",
"newType=3 order by createdate desc limit 0,10");
modelMap.put("zhengcefagui", zhengcefagui);

// 政策法规 国资委
List<Map<String, Object>> zhengcefaguigzw = getAdminService()
.select(
" jxw_news",


"Id, title, content,newType,userName,hints, issueDate,createdate",
"newType=160 order by createdate desc limit 0,15");
modelMap.put("zhengcefaguigzw", zhengcefaguigzw);

// 国资动态
List<Map<String, Object>> guozidongtai = getAdminService()
.select(
" jxw_news",
"Id, title, content,newType,userName,hints, issueDate,createdate",
"newType=22 order by createdate desc limit 0,10");
modelMap.put("guozidongtai", guozidongtai);

// 国资动态 国资委
List<Map<String, Object>> guozidongtaigzw = getAdminService()
.select(
" jxw_news",
"Id, title, content,newType,userName,hints, issueDate,createdate",
"newType=161 order by createdate desc limit 0,15");
modelMap.put("guozidongtaigzw", guozidongtaigzw);

// 通知公告
List<Map<String, Object>> tongzhigonggao = getAdminService()
.select(
" jxw_news",
"Id, title, content,newType,userName,hints, issueDate,createdate",
"newType=6 order by createdate desc limit 0,10");
modelMap.put("tongzhigonggao", tongzhigonggao);

// 企业资讯
List<Map<String, Object>> qiyezixun = getAdminService()
.select(
" jxw_news",
"Id, title, content,newType,userName,hints, issueDate,createdate",
"newType=16 order by createdate desc limit 0,10");
modelMap.put("qiyezixun", qiyezixun);

// 企业动态
List<Map<String, Object>> qiyedongtai = getAdminService()
.select(
" jxw_news",
"Id, title, content,newType,userName,hints, issueDate,createdate",
"newType=17 order by createdate desc limit 0,10");
modelMap.put("qiyedongtai", qiyedongtai);

// 重点工程
List<Map<String, Object>> zhongdiangongcheng = getAdminService()
.select(
" jxw_news",
"Id, title, content,newType,userName,hints, issueDate,createdate",
"newType=18 order by createdate desc limit 0,10");
modelMap.put("zhongdiangongcheng", zhongdiangongcheng);

List<Map<String, Object>> rows = getAdminService()
.select(
" jxw_renwu",
"Id, name, content,phone,email,address, createdate, files, type,sortnum,showinfront",


"type=0 order by createdate");

// 经信人物
modelMap.put("renwu", rows);

List<Map<String, Object>> rowss = getAdminService()
.select(
" jxw_renwu",
"Id, name, content,phone,email,address, createdate, files, type,sortnum,showinfront",
"type=1 order by createdate");
// 经信企业
modelMap.put("qiye", rowss);

List<Map<String, Object>> zhuanti = getAdminService()
.select(
" jxw_renwu",
"Id, name, content,phone,email,address, createdate, files, type,sortnum,showinfront",
"type=2 order by createdate");

modelMap.put("zhuanti", zhuanti);

List<Map<String, Object>> images = getAdminService()
.select(
" jxw_picnews",
"ID,title,newType,browseImage,imgurl,sortnum,content,createDate,userName,infoSource",
"browseImage=1 order by sortnum limit 0,5");// sortnum
// asc
modelMap.put("images", images);
modelMap.put("selectOption", objList);
return new ModelAndView("index2.jsp", modelMap);
}



连接池配置proxool.xml:

<?xml version="1.0" encoding="UTF-8"?>
<!--
the proxool configuration can be embedded within your own
application's. Anything outside the "proxool" tag is ignored.
-->
<something-else-entirely>
<proxool>
<alias>jxw_db</alias>
<driver-url>jdbc:mysql://192.168.1.111:3306/jxw</driver-url>
<driver-class>com.mysql.jdbc.Driver</driver-class>
<driver-properties>
<property name="user" value="root" />
<property name="password" value="rocan2012" />
</driver-properties>
<simultaneousBuildThrottle>69</simultaneousBuildThrottle>
<minimum-connection-count>20</minimum-connection-count>
<maximum-connection-count>200</maximum-connection-count>
<house-keeping-test-sql>select 0</house-keeping-test-sql>
<trace>true</trace>
</proxool>
</something-else-entirely> java jdbc 内存溢出 异常 exception


[解决办法]
楼主用的是oracle吗?
是不是驱动版本的问题啊
[解决办法]
<simultaneousBuildThrottle>69</simultaneousBuildThrottle>

<minimum-connection-count>20</minimum-connection-count>
<maximum-connection-count>200</maximum-connection-count>

这个设置的不合理,改为
<simultaneousBuildThrottle>20</simultaneousBuildThrottle>
<minimum-connection-count>5</minimum-connection-count>
<maximum-connection-count>50</maximum-connection-count>
[解决办法]
看看你写的数据库连接 释放自动释放
[解决办法]

换个连接池试试,会不会是BUG
[解决办法]
设置一个 <house-keeping-sleep-time>50000</house-keeping-sleep-time>
会不会好些
[解决办法]
没个项目 都有最大并发承载量,最多就是优化一下,让并发可以多些,无法做到 无限并发,所以你这根本是在压力测试呀

读书人网 >J2EE开发

热点推荐