原来在Tomcat里测试都是好好的,后来重新装了下Tomcat,测试就出错了。
log文件部分内容如下:
>>>>>>>LOG4J<<<<<<< 0 2009-04-27 17:54:49,328 ERROR [org.hibernate.util.JDBCExceptionReporter] - Connections could not be acquired from the underlying database!
>>>>>>>LOG4J<<<<<<< 1000 2009-04-27 17:54:50,328 ERROR [org.hibernate.util.JDBCExceptionReporter] - Connections could not be acquired from the underlying database!
>>>>>>>LOG4J<<<<<<< 1000 2009-04-27 17:54:50,328 ERROR [org.hibernate.tool.hbm2ddl.SchemaUpdate] - could not get database metadata
java.sql.SQLException: Connections could not be acquired from the underlying database!
at com.mchange.v2.sql.SqlUtils.toSQLException(SqlUtils.java:104)
at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutPooledConnection(C3P0PooledConnectionPool.java:264)
at com.mchange.v2.resourcepool.BasicResourcePool.awaitAcquire(BasicResourcePool.java:972)
at com.mchange.v2.resourcepool.BasicResourcePool.checkoutResource(BasicResourcePool.java:208)
at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutPooledConnection(C3P0PooledConnectionPool.java:260)
... 52 more
>>>>>>>LOG4J<<<<<<< 1093 2009-04-27 17:54:50,421 ERROR [org.hibernate.tool.hbm2ddl.SchemaUpdate] - could not complete schema update
java.sql.SQLException: Connections could not be acquired from the underlying database!
at com.mchange.v2.sql.SqlUtils.toSQLException(SqlUtils.java:104)
at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutPooledConnection(C3P0PooledConnectionPool.java:264)
at com.mchange.v2.c3p0.PoolBackedDataSource.getConnection(PoolBackedDataSource.java:94)

... 52 more
>>>>>>>LOG4J<<<<<<< 29156 2009-04-27 17:55:18,484 ERROR [org.hibernate.util.JDBCExceptionReporter] - Connections could not be acquired from the underlying database!
>>>>>>>LOG4J<<<<<<< 29172 2009-04-27 17:55:18,500 ERROR [org.hibernate.util.JDBCExceptionReporter] - Connections could not be acquired from the underlying database!
>>>>>>>LOG4J<<<<<<< 90312 2009-04-27 17:56:19,640 ERROR [org.hibernate.util.JDBCExceptionReporter] - Connections could not be acquired from the underlying database!
>>>>>>>LOG4J<<<<<<< 90312 2009-04-27 17:56:19,640 ERROR [org.hibernate.util.JDBCExceptionReporter] - Connections could not be acquired from the underlying database!
>>>>>>>LOG4J<<<<<<< 90312 2009-04-27 17:56:19,640 ERROR [org.hibernate.util.JDBCExceptionReporter] - An SQLException was provoked by the following failure: com.mchange.v2.resourcepool.ResourcePoolException: A ResourcePool cannot acquire a new resource -- the factory or source appears to be down.
>>>>>>>LOG4J<<<<<<< 90312 2009-04-27 17:56:19,640 ERROR [org.hibernate.util.JDBCExceptionReporter] - An SQLException was provoked by the following failure: com.mchange.v2.resourcepool.ResourcePoolException: A ResourcePool cannot acquire a new resource -- the factory or source appears to be down.
请多多指教。

解决方案 »

  1.   

    你有把所有JAR都放进去吗,还有数据库服务开了没?
      

  2.   

    JAR本来就放在当前web应用的lib目录下,并没有直接放到Tomcat的lib目录下,没有做任何修改;
    数据库服务开了。
      

  3.   

    Connections could not be acquired from the underlying database! 
    数据库连接出现了问题,问题很有可能是以下几个:
    你使用的是不是jndi,连接池跟tomcat有关,你是不是没有配置应用跟tomcat?
    在数据库那边,你检查一下,用其他程序能不能连接到数据库。
    主要应该不是tomcat的问题,我怀疑是你tomcat的配置出什么问题了,你试下用这个tomcat,跟其他应用看看可以一起使用不。
      

  4.   

    很明显,链接数据库错误。请检查链接的URl参数、用户名密码和数据库驱动是否正常。可以先去掉连接池试一下。 
      

  5.   

    很明显,链接数据库错误。请检查链接的URl参数、用户名密码和数据库驱动是否正常。可以先去掉连接池试一下。 
      

  6.   

    这个问题 很显然 
    Tomcat\lib 下面没有 JDBC驱动包
    拷一个JDBC驱动包到Tomcat\lib 下面
    问题 就应该解决了
      

  7.   

    这个问题我也遇到,我在C/S的情况遇到的。本地连接没问题只要开远程连接就出问题。
    所以我判断跟用户名密码和数据库驱动是否正常没有太大关系。跟tomcat也没有关系。
    因为,我没有用tomcat.报的错误是相同的。
    我的判断是,可能是连接的释放问题,或连接权限问题。
      

  8.   

    我这两天也碰到了相同的问题,我是把原来运行成功的系统装到别的电脑上时。昨天是不行的,错误跟你一模一样,但昨天好了,也可以正常运行,今天早上又出现了相同的错误,我把机器重启了一下,又好了,但下午又不行了。这时我的真实经历,希望对你有帮助。祝你好运,兄弟!
    Exception in thread "main" org.hibernate.exception.GenericJDBCException: Cannot open connection
    at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:103)
    at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:91)
    at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
    at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:29)
    at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:426)
    at org.hibernate.jdbc.ConnectionManager.getConnection(ConnectionManager.java:144)
    at org.hibernate.jdbc.JDBCContext.connection(JDBCContext.java:119)
    at org.hibernate.transaction.JDBCTransaction.begin(JDBCTransaction.java:57)
    at org.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:1326)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.hibernate.context.ThreadLocalSessionContext$TransactionProtectionWrapper.invoke(ThreadLocalSessionContext.java:301)
    at $Proxy0.beginTransaction(Unknown Source)
    at com.kettas.util.HibernateUtil.beginTransaction(HibernateUtil.java:17)
    at com.kettas.biz.impl.UserBizImpl.insertUser(UserBizImpl.java:27)
    at com.kettas.util.TestUserBiz.main(TestUserBiz.java:16)
    Caused by: java.sql.SQLException: Connections could not be acquired from the underlying database!
    at com.mchange.v2.sql.SqlUtils.toSQLException(SqlUtils.java:106)
    at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutPooledConnection(C3P0PooledConnectionPool.java:529)
    at com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource.getConnection(AbstractPoolBackedDataSource.java:128)
    at org.hibernate.connection.C3P0ConnectionProvider.getConnection(C3P0ConnectionProvider.java:56)
    at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:423)
    ... 13 more
    Caused by: com.mchange.v2.resourcepool.CannotAcquireResourceException: A ResourcePool could not acquire a resource from its primary factory or source.
    at com.mchange.v2.resourcepool.BasicResourcePool.awaitAvailable(BasicResourcePool.java:1319)
    at com.mchange.v2.resourcepool.BasicResourcePool.prelimCheckoutResource(BasicResourcePool.java:557)
    at com.mchange.v2.resourcepool.BasicResourcePool.checkoutResource(BasicResourcePool.java:477)
    at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutPooledConnection(C3P0PooledConnectionPool.java:525)
    ... 16 more
      

  9.   

    我个人认为是连接池出现的错误
    你的连接池和你tomcat有关
    你原来的连接池里面的连接没有释放掉
    造成的无法获取
      

  10.   

    改改VO的类型,如:数据中用的NUMBER(14),而VO里面用的是Integer就会出现这个问题!
    可以把VO里面的类型改为Long,就可以了
      

  11.   

    添加个数据库驱动包就可以了 比如ojdbc14.jar    放在lib里