`
Sev7en_jun
  • 浏览: 1227493 次
  • 性别: Icon_minigender_1
  • 来自: 广州
博客专栏
84184fc0-d0b6-3f7f-a3f0-4202acb3caf5
Apache CXF使用s...
浏览量:111466
社区版块
存档分类
最新评论

解决:Connections could not be acquired from the underlying database!

 
阅读更多

og4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
org.quartz.SchedulerConfigException: Failure occured during job recovery. [See nested exception: org.quartz.JobPersistenceException: Failed to obtain DB connection from data source 'myDS': java.sql.SQLException: Connections could not be acquired from the underlying database! [See nested exception: java.sql.SQLException: Connections could not be acquired from the underlying database!]]
 at org.quartz.impl.jdbcjobstore.JobStoreSupport.schedulerStarted(JobStoreSupport.java:693)
 at org.quartz.core.QuartzScheduler.start(QuartzScheduler.java:580)
 at org.quartz.impl.StdScheduler.start(StdScheduler.java:142)
 at org.quartz.ee.servlet.QuartzInitializerListener.contextInitialized(QuartzInitializerListener.java:198)
 at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3830)
 at org.apache.catalina.core.StandardContext.start(StandardContext.java:4337)
 at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
 at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
 at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
 at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
 at org.apache.catalina.core.StandardService.start(StandardService.java:516)
 at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
 at org.apache.catalina.startup.Catalina.start(Catalina.java:566)
 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:597)
 at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
 at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
Caused by: org.quartz.JobPersistenceException: Failed to obtain DB connection from data source 'myDS': java.sql.SQLException: Connections could not be acquired from the underlying database! [See nested exception: java.sql.SQLException: Connections could not be acquired from the underlying database!]
 at org.quartz.impl.jdbcjobstore.JobStoreSupport.getConnection(JobStoreSupport.java:777)
 at org.quartz.impl.jdbcjobstore.JobStoreTX.getNonManagedTXConnection(JobStoreTX.java:71)
 at org.quartz.impl.jdbcjobstore.JobStoreSupport.executeInNonManagedTXLock(JobStoreSupport.java:3774)
 at org.quartz.impl.jdbcjobstore.JobStoreSupport.executeInNonManagedTXLock(JobStoreSupport.java:3739)
 at org.quartz.impl.jdbcjobstore.JobStoreSupport.recoverJobs(JobStoreSupport.java:833)
 at org.quartz.impl.jdbcjobstore.JobStoreSupport.schedulerStarted(JobStoreSupport.java:691)
 ... 18 more
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.quartz.utils.PoolingConnectionProvider.getConnection(PoolingConnectionProvider.java:247)
 at org.quartz.utils.DBConnectionManager.getConnection(DBConnectionManager.java:108)
 at org.quartz.impl.jdbcjobstore.JobStoreSupport.getConnection(JobStoreSupport.java:774)
 ... 23 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)
 ... 27 more

 

 

以上问题可能有一下原因造成:

1,驱动配置有误:driver=com.mysql.jdbc.Driver
2,数据库连接地址有误:url=jdbc:mysql://localhost:3306/test?3useUnicode=true&characterEncoding=utf8
3,密码或帐号有误:username=root
      password=root

4,数据库未启动或无权访问

5,项目未引入对应的驱动jar包mysql-connector-java-5.1.6-bin.jar

6,mysql root没有远程访问的权限,需要增加权限,增加权限的步骤如下:
进入mysql数据库:
grant all privileges on *.* to 'root'@'%' identified by 'root' with grant option;
flush privileges;

 

如果你也遇到过以上问题,但原因不是上面5种,请分享下解决方法,谢谢

4
5
分享到:
评论
11 楼 iijjll 2016-08-15  
今天我也遇到这个问题了,情况是本机调试正常,项目发布到linux服务器就报这个异常了。
原因是xml文件的dataSource没有加载c3p0.properties里面的参数,直接写死就正常了。
等会再去查下什么原因。
10 楼 i_t_e_y_e 2015-02-06  
mysql spring3 mybatis3 c3p0 cglib
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="basePackage" value=""/>
</bean>
多配置<property name="sqlSessionFactory" ref="sqlSessionFactory"/>
9 楼 ctz_131415 2015-02-02  
09:10:08,302 ERROR JDBCExceptionReporter:101 - Connections could not be acquired from the underlying database!
09:10:37,929 ERROR JDBCExceptionReporter:101 - Connections could not be acquired from the underlying database!
09:10:37,932 ERROR SchemaUpdate:175 - 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: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.springframework.orm.hibernate3.LocalDataSourceConnectionProvider.getConnection(LocalDataSourceConnectionProvider.java:82)
at org.hibernate.tool.hbm2ddl.SuppliedConnectionProviderConnectionHelper.prepare(SuppliedConnectionProviderConnectionHelper.java:51)
at org.hibernate.tool.hbm2ddl.SchemaUpdate.execute(SchemaUpdate.java:168)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:346)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1327)
8 楼 swallowly 2014-11-04  
在普通java项目中使用 mybatis+C3p0+spring时也遇见上述问题。

问题原因是:在xml配置文件中显示声明了自动装载  <beans default-autowire="byName">
    几经折腾,把自动装载设置去掉,就没有问题了,应该使用默认的 byType
7 楼 hyk1984 2014-11-03  
兄弟,我遇到过,一个问题,是由同一个ip在短时间内产生太多(超过mysql数据库max_connection_errors的最大值)中断的数据库连接而导致的阻塞,引发的。
当时解决方式:
重启数据库服务。(确认可行。理论上是只治标不治本,但目前为止,未出现问题)
据说还可以:
使用mysqladmin flush-hosts 命令清理一下hosts文件。(未确认能不能解决)
6 楼 IT_LDB 2014-08-06  
   password配置错误.
5 楼 jxhow 2014-04-23  
今天碰到了另一种情况,maven+spring 项目,用了org.apache.tomcat.jdbc.pool.DataSource;  报错:Could not get JDBC Connection; nested exception is java.sql.SQLException: com.mysql.jdbc.Driver;检查后,需要加入 tomcat-jdbc的引用。
4 楼 Sev7en_jun 2014-04-08  
zfwdl2005 写道
兄弟,给你加一条,以便后面看到的兄弟们用得上;

还有一种情况,就是mysql root没有远程访问的权限,需要增加权限,增加权限的步骤如下:
进入mysql数据库:
grant all privileges on *.* to 'root'@'%' identified by 'root' with grant option;
flush privileges;

OK
3 楼 zfwdl2005 2014-04-06  
兄弟,给你加一条,以便后面看到的兄弟们用得上;

还有一种情况,就是mysql root没有远程访问的权限,需要增加权限,增加权限的步骤如下:
进入mysql数据库:
grant all privileges on *.* to 'root'@'%' identified by 'root' with grant option;
flush privileges;
2 楼 gwj879 2014-02-27  
感激!结果是地址里:& 变成了&amb
1 楼 qmx_zhq 2014-01-01  
看看bulid path下是不是加载了所需的jar包。如:使用MyEclipse,看看java build path下的jar包有没有问题。
我遇到时,是因为项目中通过外部引用的jar包,然后,外部jar包位置变了,我又加入了lib目录。导致java build path有问题,注意Tomcat对class的加载顺序。

加载的优先顺序一览

1.最先是$JAVA_HOME/jre/lib/ext/下的jar文件。

2.环境变量CLASSPATH中的jar和class文件。

3.$CATALINA_HOME/common/classes下的class文件。

4.$CATALINA_HOME/commons/endorsed下的jar文件。

5.$CATALINA_HOME/commons/i18n下的jar文件。

6.$CATALINA_HOME/common/lib 下的jar文件。
(JDBC驱动之类的jar文件可以放在这里,这样就可以避免在server.xml配置好数据源却出现找不到JDBC Driver的情况。)
7.$CATALINA_HOME/server/classes下的class文件。

8.$CATALINA_HOME/server/lib/下的jar文件。

9.$CATALINA_BASE/shared/classes 下的class文件。

10.$CATALINA_BASE/shared/lib下的jar文件。

11.各自具体的webapp /WEB-INF/classes下的class文件。

相关推荐

    有关数据库连接的问题

    databaseName=TestJavaOdbc"; Connection conn = DriverManager.getConnection(url); ``` #### 使用ODBC连接 除了直接使用JDBC驱动外,还可以通过ODBC桥接的方式连接SQL Server: 1. **加载ODBC驱动**: ```...

    mysql密码过期导致连接不上mysql

    初始为500,结果还是错误, 在修改为36000,并且加大了c3p0连接数cpool.maxPoolSize=100 这个时候出现下面错误现象2 Connections could not be acquired from the underlying database! 一直没有定位出来,靠,

    dbconfig.properties

    Connections could not be acquired from the underlying database,在正确导入所需jar包和安装合适版本的tomcat后,出现该问题,大多数是数据库连接部署,要仔细审查一下数据库配置

    mysql安装失败

    win7 系统 the security settings could not be applied to the database 在安装mysql的时候,就会遇到以下错误。遇到错误不可怕,怕的就是被错误所击倒! The security settings could not be applied to the ...

    boostdesc_bgm.i,vgg_generated_48.i等.zip

    Couldn't connect to server from the Internet. Perhaps direct connections are not allowed in the current network. To use proxy please check/specify these environment variables: - ...

    mingyang66#spring-parent#RabbitMQ学习笔记:Connections、Channels、Queue

    RabbitMQ学习笔记:Connections、Channels、Queues之state状态连接、信道、队列状态如下:GitHub地址:https://gi

    MyEclipse报错说明

    10. **Connections could not be acquired from the underlying database** 无法从底层数据库获取连接,这可能是由于数据库URL配置错误、网络问题或数据库服务未启动等原因造成的。检查数据库连接参数和数据库...

    Dimeric.Virtual.Database.

    VDB provides abstraction for the underlying database SQL dialect. VDB provides an escape syntax so that you can write the same SQL regardless of the database you are connecting to. This escape syntax...

    计算机网络第六版答案

    but the time when loss first occurs will be different from one experiment to the next due to the randomness in the emission process. 22. Five generic tasks are error control, flow control, ...

    微软内部资料-SQL性能优化3

    To make use of either more or less strict isolation levels in applications, locking can be customized for an entire session by setting the isolation level of the session with the SET TRANSACTION ...

    解决mysql 1040错误Too many connections的方法

    mysql官方告诉我们需要修改max_connections的值,那么我们怎么去修改呢?有两种方法 1、修改配置文件文件 修改/etc/my.cnf这个文件,在[mysqld]中新增max_connections=N,如果你没有这个文件请从编译源码中的support...

    KafkaOffsetMonitor监控工具2017年1月发布的版本

    Graphs could sometimes be difficult to read because you would see non-whole numbers on the y-axis legend, when facts being drawn are always whole numbers. Set y-axis to draw only whole numbers in the ...

    AWS certified solutions architect associate exam sample

    - **Database Visible Metrics**: Metrics such as the number of connections are not part of the basic monitoring package. #### 6. Operational Process Performed by AWS for Data Security - **Operational...

    Absolute Database for D7

    no DLLs No special installation or configuration required Database engine compiles right into EXE Single-file database format Database file could be merged with the application EXE file High Speed ...

    Java邮件开发Fundamentals of the JavaMail API

    be protocol agnostic, you can't overcome the limitations of the underlying protocols. If a capability isn't supported by a chosen protocol, the JavaMail API doesn't magically add the capability on ...

    sqlmap (懂的入)

    * SQL injection testing and detection does not depend upon the web application database management system back-end. SQL injection exploiting and query syntax obviously depend upon the web ...

    端口查看工具

    port is filtered by the other CurrPorts options and it's not displayed in the main window, it won't be displayed in the tray balloon.) * Version 1.87: o Improved the 'User Name' column. If you ...

    Oracle sqldeveloper without jdk (win+linux)

    - Bug 4924484: Values to which NCHAR, NVARCHAR2, or NCLOB columns are modified may be unnecessarily converted to the database character set before being converted to the national character set and ...

    weblogic 8.X 无限制

    The Server is not licensed for this operation.Connection rejected, the server license allows connections from only 5 unique IP addresses. 没有授权 提示5个IP访问的限制 解决办法: 从licensecodes.oracle...

Global site tag (gtag.js) - Google Analytics