weblogic.common.resourcepool.ResourceLimitException: No resources currently available in pool JDBC Data Source-0 to allocate to applications, please increase the size of the pool and retry..
java.lang.NullPointerException
at com.yulong.share.tool.SqlUtil.getRowCount(SqlUtil.java:62)
at com.yulong.back.action.codemanager.CodeAction.listCode(CodeAction.java:49)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:274)
at org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:194)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:419)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194)
at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:743)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:225)
at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:127)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:283)
at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
at com.yulong.share.tool.EncodingFilter.doFilter(EncodingFilter.java:34)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
at weblogic.servlet.internal.RequestEventsFilter.doFilter(RequestEventsFilter.java:26)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3212)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)
at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:1983)
at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:1890)
at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1344)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:181)请教各位高手,我有个项目,在一开始启动没有问题,速度操作等都很正常,但后台管理模块操作一段时间后就出现这个问题,重新启动又正常了,大家有遇到过这样的问题吗?
以下是代码:
public int getRowCount(String sql)
   {
     ResultSet rs = null;
     Statement stmt = null;
     Connection conn = null;
     int rows = 0;
     try
     {
       conn = getConnection();
       stmt = getConnection().createStatement(
         1004, 
         1007);
       rs = stmt.executeQuery("select count(1) from (select a.* from (" + 
         sql + ") a )");
       if (rs.next())
         rows = rs.getInt(1);
     }
     catch (Exception ex) {
       ex.printStackTrace();
       try
       {
         if (rs != null)
           rs.close();
         if (stmt != null)
           stmt.close();
         if (conn != null)
           conn.close();
       } catch (SQLException e) {
         this.m_log.warn(e.toString());
       }
     }
     finally
     {
       try
       {
         if (rs != null)
           rs.close();
         if (stmt != null)
           stmt.close();
         if (conn != null)
           conn.close();
       } catch (SQLException e) {
         this.m_log.warn(e.toString());
       }
     }
     return rows;
   }

解决方案 »

  1.   

    连接泄露。
    记得及时close连接。

      try
      {
      if (rs != null)
      rs.close();
      if (stmt != null)
      stmt.close();
      if (conn != null)
      conn.close();
      } catch (SQLException e) {
      this.m_log.warn(e.toString());
      }
    分成3个try试试看。
      

  2.   

    No resources currently available in pool JDBC Data Source-0 to allocate to applications, please increase the size of the pool and retry..数据源连接池已经耗尽了。。  获取不到连接了,所以报错了把连接池设置大一点。然后检查一下代码,看那些地方没有释放连接的。
      

  3.   


    马工早啊,这么早就来CSDN抢分分了啊。
      

  4.   

    连接池满了
    如果你每次使用完都有及时close连接,那就是你的连接池设置数量不能满足你的业务需求,需要给连接池扩容。
    小项目的话通常都是没有及时close连接造成的
      

  5.   

    改成这样,还是报错: weblogic.common.resourcepool.ResourceLimitException: No resources currently available in pool JDBC Data Source-0 to allocate to applications, please increase the size of the pool and retry..public int getRowCount(String sql)
       {
         ResultSet rs = null;
         Statement stmt = null;
         Connection conn = null;
         int rows = 0;
         try
         {
           conn = getConnection();
           stmt = getConnection().createStatement(
             1004, 
             1007);
           rs = stmt.executeQuery("select count(1) from (select a.* from (" + 
             sql + ") a )");
           if (rs.next())
             rows = rs.getInt(1);
         }
         catch (Exception ex) {
           ex.printStackTrace();
           try
           {
             if (rs != null)
               rs.close();
           } catch (SQLException e) {
             this.m_log.warn(e.toString());
           }
           try
           {
            if (stmt != null)
                   stmt.close();
           } catch (SQLException e) {
             this.m_log.warn(e.toString());
           }
           try
           {
             if (conn != null)
               conn.close();
           } catch (SQLException e) {
             this.m_log.warn(e.toString());
           }
         }
         finally
         {
           try
           {
             if (rs != null)
               rs.close();
           } catch (SQLException e) {
             this.m_log.warn(e.toString());
           }
           try
           {
            if (stmt != null)
                   stmt.close();
           } catch (SQLException e) {
             this.m_log.warn(e.toString());
           }
           try
           {
             if (conn != null)
               conn.close();
           } catch (SQLException e) {
             this.m_log.warn(e.toString());
           }
         }
         return rows;
       }
      

  6.   

    为什么不用
    stmt = conn.createStatement()呢?
      

  7.   

      conn = getConnection();
      stmt = getConnection().createStatement(
      1004, 
      1007);这样有可能拿了两个连接过来
    而最后只关闭一个连接
    象楼上说的那样改吧
      

  8.   

    各位好,原因已经解决了,createStatement(1004,1007)这里的参数没有问题,原因是
      conn = getConnection();//第一个连接
      stmt = getConnection().createStatement(1004,1007)//第二个连接,没有关