postgres:查询数据库

时间:2017-05-05 07:08:37

标签: postgresql

项目在找不到数据库连接后运行一段时间,错误信息如下:

2017-05-02 10:02:17,224 ERROR [main](line:com.unis.license.agent.management.aop.ManagementServicesAop.afterThrowing(ManagementServicesAop.java:47)) - BeforeMethod:com.unis。 license.agent.management.service.impl.LicenseServiceImpl.loadLicenseInfo参数:[] 2017-05-02 10:02:17,225 ERROR [main](行:com.unis.license.agent.management.aop.ManagementServicesAop.afterThrowing(ManagementServicesAop.java:50)) - methodException:com.unis.license.agent .management.service.impl.LicenseServiceImpl.loadLicenseInfo例外:org.mybatis.spring.MyBatisSystemException:嵌套异常是org.apache.ibatis.exceptions.PersistenceException:

查询数据库时出错。原因:org.springframework.jdbc.CannotGetJdbcConnectionException:无法获取JDBC连接;嵌套异常是org.apache.commons.dbcp.SQLNestedException:无法创建PoolableConnectionFactory(FATAL:数据库系统正在启动)

licenseAgent / orm / LicenseInfo.xml

中可能存在错误

该错误可能涉及com.unis.license.agent.management.dao.ILicenseInfoOper.getAll

执行查询时发生错误

原因:org.springframework.jdbc.CannotGetJdbcConnectionException:无法获取JDBC连接;嵌套异常是org.apache.commons.dbcp.SQLNestedException:无法创建PoolableConnectionFactory(FATAL:数据库系统正在启动)

2017-05-02 10:02:17,226 ERROR [main](行:org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:318)) - 上下文初始化失败 org.springframework.beans.factory.BeanCreationException:创建名为' com.unis.license.agent.management.filter.Initialization#0'的bean时出错。在类路径资源[spring-context.xml]中定义:init方法的调用失败;嵌套异常是org.springframework.transaction.NoTransactionException:范围内没有事务方面管理的TransactionStatus         在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1553)         在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)         在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475)         at org.springframework.beans.factory.support.AbstractBeanFactory $ 1.getObject(AbstractBeanFactory.java:304)         在org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)         在org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:300)         在org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:195)         at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:700)         在org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:760)         at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:482)         在org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:381)         在org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:293)         在org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106)         at org.eclipse.jetty.server.handler.ContextHandler.callContextInitialized(ContextHandler.java:799)         at org.eclipse.jetty.servlet.ServletContextHandler.callContextInitialized(ServletContextHandler.java:446)         at org.eclipse.jetty.server.handler.ContextHandler.startContext(ContextHandler.java:791)         at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:296)         at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1347)         在org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:743)         在org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:492)         at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:69)         在org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:117)         在org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:99)         在org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:60)         at org.eclipse.jetty.server.handler.ContextHandlerCollection.doStart(ContextHandlerCollection.java:154)         at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:69)

我的DataSource配置信息如下:

<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
    <property name="driverClassName" value="org.postgresql.Driver"></property>
    <property name="url" value="jdbc:postgresql://127.0.0.1:5432/ucsm"></property> 
    <property name="username" value="uqdm"></property>
    <property name="password" value="unis123"></property>
    <property name="maxActive" value="100"></property>
    <property name="maxIdle" value="30"></property>
    <property name="maxWait" value="500"></property>
    <property name="defaultAutoCommit" value="true"></property>
</bean>
<bean id="transactionManager"
    class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
    <property name="dataSource" ref="dataSource" />
</bean>
<tx:annotation-driven transaction-manager="transactionManager" />

<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
    <property name="configLocation" value="classpath:licenseAgent/mybatiscfg.xml"></property>
    <property name="dataSource" ref="dataSource" />
</bean> 
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
    <property name="basePackage" value="com.unis.license.agent.management.dao" />
</bean>

1 个答案:

答案 0 :(得分:0)

这是堆栈跟踪的关键部分:

FATAL: the database system is starting up

这意味着PostgreSQL服务器正在启动或重新启动,尚未准备好接受连接。

您应该检查PostgreSQL服务器日志以找到意外启动的原因。

可能是由于崩溃的PostgreSQL服务器进程导致重启。这种崩溃可能是由于错误的服务器扩展,错误的硬件或PostgreSQL错误引起的(粗略的可能性)。