我使用的是Tomcat的连接池
当服务器运行一天后就会报错,重启Tomcat就好了,又能坚持一天
连接池配置信息:
<Resource name="jdbc/TEST" auth="Container" type="javax.sql.DataSource" driverClassName="com.microsoft.jdbc.sqlserver.SQLServerDriver" url="jdbc:microsoft:sqlserver://192.168.1.119:1433;DatabaseName=Test" username="sa" password="123456" maxActive="300" maxIdle="30" maxWait="5000"/>
下面是报错信息:
org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot get a connection, pool error Timeout waiting for idle object请问大侠 这是怎么回事

解决方案 »

  1.   

    你的程序中可能未关闭connection,导致没有空闲连接可用。
      

  2.   

    不可能!难道我的函数写错了 ?
      try {
              String s_sql="select * from clandb_ah.dbo.guild where llevel > 0 order by regdate desc  ";
              stmt = conn.prepareStatement(s_sql);
              rs = stmt.executeQuery();
                    while (rs.next()) {
                            obj = new TeamImp(rs.getInt("ssn"));
                        list.add(obj);
                    }
                   rs.close();
                    } catch (Exception e) {
                            System.out.println(e.toString());
                    } finally {
                            try {
                                    if (stmt != null)
                                            stmt.close();
                                            stmt = null;
                                    if (conn != null)
                                            conn.close();
                                            conn = null;
                            } catch (SQLException e) {
                                    System.out.println(e);
                            }
                    }
      

  3.   

    把类的作用域改成session 试试
      

  4.   

    你把错误信息打出来看看嘛 e.getMessage() 看是说什么
      

  5.   

    --------------
    谢谢,我刚才遇到这个问题。就是把未关闭的connection关闭掉而解决了