如何登录org.springframework.jdbc.CannotGetJdbcConnectionException JDBC连接信息

问题描述 投票:0回答:1

我的工作,它使用与ibatis的和C3P0连接池组合Spring框架的应用程序。该系统连接到大约12单独的数据库。

当某个数据库无法访问,我得到了这是由弹簧(见下文)所产生的日志文件堆栈跟踪。然而,这个记录丢失在其上的数据库无法达成非常重要的信息。

基本上,我想JDBC连接字符串(没有密码),以在连接错误记录。有一个简单的方法来告诉Spring登录吗?

Invocation of init method failed; nested exception is org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is java.sql.SQLException: Connections could not be acquired from the underlying database!
Caused by: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is java.sql.SQLException: Connections could not be acquired from the underlying database!
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.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:113)
        at org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy.getConnection(TransactionAwareDataSourceProxy.java:109)
        at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:113)
        at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:79)
        at org.springframework.orm.ibatis.SqlMapClientTemplate.execute(SqlMapClientTemplate.java:183)
        at org.springframework.orm.ibatis.SqlMapClientTemplate.queryForObject(SqlMapClientTemplate.java:242)

....

java spring jdbc c3p0
1个回答
0
投票

您可以启用在Spring的ORM层记录,像这样(假设你使用log4j的):

log4j.logger.org.springframework.orm =微量,DEBUGLOG

您还可以使用P6Spy来记录你的数据库连接。

最后,如何在你的IDE上的SQLException设置一个断点(休息的时候这个异常被抛出)?

© www.soinside.com 2019 - 2024. All rights reserved.