我正在使用liferay 6.1并创建了我的自定义portlet,并且我正在使用自定义查询,它直接从数据库中获取记录,并带有以下......
public List<DashBoardBean> GetPieChartDataForCampaignbyOrganization(
ThemeDisplay pThemeDisplay) {
log.info("In GetPieChartDataForCampaignbyOrganization ");
Context CtxObj;
long pParentOrgId;
ResultSet advResultSet = null;
List<DashBoardBean> dashboardbeanObjList = new ArrayList<DashBoardBean>();
try {
CtxObj = new InitialContext();
DataSource DsObj = (DataSource) CtxObj
.lookup("java:comp/env/jdbc/Liferay");
Connection ConObj = DsObj.getConnection();
Statement sStmtObj = ConObj.createStatement();
advResultSet = sStmtObj
.executeQuery("MY CUSTOM QUERY WILL BE HERE");
while (advResultSet.next()) {
DashBoardBean dashboardbeanObj = new DashBoardBean();
dashboardbeanObj
.setsOrganizationName(advResultSet.getString(1));
dashboardbeanObj.setlOrganizationCount(advResultSet.getLong(2));
dashboardbeanObjList.add(dashboardbeanObj);
}
} catch (NamingException e) {
// TODO Auto-generated catch block
dashboardbeanObjList = null;
e.printStackTrace();
} catch (SQLException e) {
dashboardbeanObjList = null;
// TODO Auto-generated catch block
e.printStackTrace();
} catch (PortalException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SystemException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
log.info("Leave GetPieChartDataForCampaignbyOrganization ");
return dashboardbeanObjList;
}
以上是我的一个函数的代码片段...我有超过 5 个具有相同结构的函数...只是 SQL 查询在功能上有所不同...
现在的问题是我必须在页面加载中调用超过 5 个这样的函数......所以当我经常重新加载页面时......它给了我如下错误......
org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot get a connection, pool error Timeout waiting for idle object
at org.apache.tomcat.dbcp.dbcp.PoolingDataSource.getConnection(PoolingDataSource.java:114)
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.java:1044)
at emenu.advertise.appbl.DashBoardCustomQuery.GetPieChartDataForCampaignStatus(DashBoardCustomQuery.java:112)
at emenu.advertise.appbl.DashBordBL.GetPieChartDataForCampaignStatus(DashBordBL.java:292)
at emenu.advertise.portlet.RestaurantPortlet.serveResource(RestaurantPortlet.java:402)
at com.liferay.portlet.FilterChainImpl.doFilter(FilterChainImpl.java:118)
at com.liferay.portal.kernel.portlet.PortletFilterUtil.doFilter(PortletFilterUtil.java:71)
at com.liferay.portal.kernel.servlet.PortletServlet.service(PortletServlet.java:111)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:72)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilter.doFilter(InvokerFilter.java:73)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:684)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:471)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:402)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:329)
at com.liferay.portlet.InvokerPortletImpl.invoke(InvokerPortletImpl.java:531)
at com.liferay.portlet.InvokerPortletImpl.invokeResource(InvokerPortletImpl.java:626)
at com.liferay.portlet.InvokerPortletImpl.serveResource(InvokerPortletImpl.java:436)
at com.liferay.portal.action.LayoutAction.processPortletRequest(LayoutAction.java:1075)
at com.liferay.portal.action.LayoutAction.processLayout(LayoutAction.java:719)
at com.liferay.portal.action.LayoutAction.execute(LayoutAction.java:249)
at ............................
.......java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:619)
Caused by: java.util.NoSuchElementException: Timeout waiting for idle object
at org.apache.tomcat.dbcp.pool.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:1171)
at org.apache.tomcat.dbcp.dbcp.PoolingDataSource.getConnection(PoolingDataSource.java:106)
... 131 more
09:24:11,163 INFO [http-bio-8080-exec-5][DashBoardCustomQuery:665] Leave GetHighestClickRestaurantName
09:24:11,163 INFO [http-bio-8080-exec-5][DashBoardCustomQuery:304] Leave GetLineChartDataForHighestClickedByRestaurant
09:24:11,164 INFO [http-bio-8080-exec-5][DashBordBL:166] Leave GetLineChartDataByRestaurant From DashBordBl
我知道我做错了什么...但是我不知道在哪里...可能是因为它的SQL连接刚刚从服务器丢失///是因为我没有关闭连接...请帮助我。 ..并纠正我哪里错了...我刚刚给出了一个函数示例,就像我过去从其他函数获取数据的方式一样...