spring手动注入 数据库很快连接数就超了,怎么回事?
前台是jsp调用一个后台的javabean,,在bean层手动注入Service,这样写出来后连接 速度很慢,并且很快数据库就会显示“too many connection”,,求解决方法。可以确定Service和DAO还有连接池那些是没有问题的,
jsp调用bean方式:
<jsp:useBean id="about" scope="request"
class="com.swust.kelab.web.controller.bean.AboutBean"></jsp:useBean>
<jsp:setProperty property="navId" name="about" param="naviid" />
javaBean:
public class AboutBean {
ApplicationContext ctx = new ClassPathXmlApplicationContext(
new String[] { "classpath:spring/dao.xml",
"classpath:spring/service.xml" });
private AboutService aboutService = (AboutService) ctx.getBean("AboutService");
private int navId;
public void setNavId(int navId) {
this.navId = navId;
}
public About getAboutDetail(){
About about = new About();
about = aboutService.viewOneAbout(navId);
return about;
}
}