org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot get a connection, pool er

 2008-04-26 22:35:40,812 ERROR [org.hibernate.util.JDBCExceptionReporter] - Cannot get a connection, pool error Timeout waiting for idle object

 2008-04-26 22:35:40,812 WARN [org.hibernate.util.JDBCExceptionReporter] - SQL Error: 0, SQLState: null

 2008-04-26 22:35:40,812 ERROR [org.hibernate.util.JDBCExceptionReporter] - Cannot get a connection, pool error Timeout waiting for idle object

 2008-04-26 22:35:40,812 ERROR [com.dao.MessageDAO] - find all failed

 org.springframework.jdbc.UncategorizedSQLException: Hibernate operation: Cannot open connection; uncategorized SQLException for SQL [???]; SQL state [null]; error code [0]; Cannot get a connection, pool error Timeout waiting for idle object; nested exception is org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot get a connection, pool error Timeout waiting for idle object

Caused by:

org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot get a connection, pool error Timeout waiting for idle object

  查询数据时,Spring并不能够自动管理连接,也就是说,在使用中这几句代码重视不段的获取数据库的连接,每调用一次就申请一个连接……直到 tomcat连接池中的连接耗尽……所以就再也申请不到连接了……出现了这个异常,解决办法是使用事务来管理这段代码,让Spring自动管理这段代码中 申请的连接。我使用了Spring AOP自动事务代理……配置文件如下……



    

        

            java:comp/env/SqlServer

        

        

            true

        

    

    

    

        

            

        

        

            

                

                    org.hibernate.dialect.SQLServerDialect

                

                

                true

            

        

        

            

                ./Message.hbm.xml

                ./Setting.hbm.xml

                ./Admin.hbm.xml

            

        

    

    

    

        

            

        

    

    

    

        

            

        

        

        

            

                PROPAGATION_REQUIRED

                PROPAGATION_REQUIRED

                PROPAGATION_REQUIRED

                PROPAGATION_REQUIRED

                PROPAGATION_REQUIRED               

                PROPAGATION_REQUIRED

            

        

    

    

    

        

            

                *DAO              

                gotoPage

                find

            

        

        

            

                

            

        

       

        

        

    

    

        

            

        

    

    

        

            

        

    

    

        

            

        

    

 敬请关注  大神网  获取更多 编程资讯

 

你可能感兴趣的:(技术类,android教程)