Grails Postgres验证查询。无法验证新建立的连接

时间:2017-08-07 16:05:48

标签: postgresql hibernate validation grails gorm

所以我有这个问题我真的不明白。

我有一个运行3.3.0的grails应用程序和以下属性:

    dataSource:
        dbCreate: update
        url: jdbc:postgresql://***********:5432/*******
        username: ************
        password: *************
        driverClassName: org.postgresql.Driver
        pooled: true
        properties:
            timeBetweenEvictionRunsMillis: 1000 * 60 * 30
            minEvictableIdleTimeMillis: 1000 * 60 * 30
            validationQuery: "SELECT 1"
            validationQueryTimeout: 30
            validationInterval: 15000
            testOnBorrow: true
            testWhileIdle: true
            testOnReturn: true

现在,当应用程序尝试验证时,我得到以下异常:

Caused by: java.sql.SQLException: Failed to validate a newly established connection.
        at org.apache.tomcat.jdbc.pool.ConnectionPool.borrowConnection(ConnectionPool.java:840)
        at org.apache.tomcat.jdbc.pool.ConnectionPool.borrowConnection(ConnectionPool.java:651)
        at org.apache.tomcat.jdbc.pool.ConnectionPool.getConnection(ConnectionPool.java:198)
        at org.apache.tomcat.jdbc.pool.DataSourceProxy.getConnection(DataSourceProxy.java:132)
        at org.springframework.jdbc.datasource.LazyConnectionDataSourceProxy$LazyConnectionInvocationHandler.getTargetConnection(LazyConnectionDataSourceProxy.java:403)
        at org.springframework.jdbc.datasource.LazyConnectionDataSourceProxy$LazyConnectionInvocationHandler.invoke(LazyConnectionDataSourceProxy.java:376)
        at com.sun.proxy.$Proxy74.prepareStatement(Unknown Source)
        at sun.reflect.GeneratedMethodAccessor164.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy$TransactionAwareInvocationHandler.invoke(TransactionAwareDataSourceProxy.java:240)
        at com.sun.proxy.$Proxy74.prepareStatement(Unknown Source)
        at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$5.doPrepare(StatementPreparerImpl.java:146)
        at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$StatementPreparationTemplate.prepareStatement(StatementPreparerImpl.java:172)
        ... 44 common frames omitted

我已尝试将验证查询更改为

SELECT 1 FROM SELECT now() SELECT VERSION

我还从验证查询参数中删除了引号,但没有运气。

直接在DB上运行所有这些查询会产生所需的输出。

我错过了一些非常简单的事情吗?!

0 个答案:

没有答案