2

在我的 BuildConfig.groovy

我有 :

    dependencies {         
runtime 'org.postgresql:postgresql:9.3-1100-jdbc41'
}

在我的 DataSource.groovy

我有 :

dataSource {

pooled = true
driverClassName = "org.postgresql.Driver"
dialect=org.hibernate.dialect.PostgreSQLDialect

hibernate {
    cache.use_second_level_cache=true
    cache.use_query_cache=true
    cache.region.factory_class = 'net.sf.ehcache.hibernate.EhCacheRegionFactory'

}
// environment specific settings
environments {
development {
dataSource {

            dbCreate = "create-drop" // one of 'create', 'create-drop','update'
            url = "jdbc:postgresql://ip:5432/security_dev"
            username = "uname"
            password = "pwd"
        }
    }
    test {
        dataSource {
            dbCreate = "create-drop" // one of 'create', 'create-drop','update'
            url = "jdbc:postgresql://ip:5432/security_dev"
            username = "uname"
            password = "pwd"

        }
    }
    production {
        dataSource {
            dbCreate = "update" // one of 'create', 'create-drop','update'
            url = "jdbc:postgresql://ip:5432/security_dev"
            username = "uname"
            password = "pwd"
        }

    }
}
}

这是错误消息

2014-04-08 15:02:48,390 [localhost-startStop-1] ERROR pool.ConnectionPool  - Unable to create initial connections of pool.
Message: Driver:org.postgresql.Driver@afd862b returned null for URL:jdbc:h2:mem:grailsDB;MVCC=TRUE;LOCK_TIMEOUT=10000
    Line | Method
->>  262 | run       in java.util.concurrent.FutureTask
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|   1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
|    615 | run . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^    744 | run       in java.lang.Thread
Error |
2014-04-08 15:02:48,708 [localhost-startStop-1] ERROR pool.ConnectionPool  - Unable to create initial connections of pool.
Message: Driver:org.postgresql.Driver@30535975 returned null for URL:jdbc:h2:mem:grailsDB;MVCC=TRUE;LOCK_TIMEOUT=10000
    Line | Method
->>  262 | run       in java.util.concurrent.FutureTask
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|   1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
|    615 | run . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^    744 | run       in java.lang.Thread
Error |
2014-04-08 15:02:48,723 [localhost-startStop-1] ERROR pool.ConnectionPool  - Unable to create initial connections of pool.
Message: Driver:org.postgresql.Driver@563105a6 returned null for URL:jdbc:h2:mem:grailsDB;MVCC=TRUE;LOCK_TIMEOUT=10000
    Line | Method
->>  262 | run       in java.util.concurrent.FutureTask
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|   1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
|    615 | run . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^    744 | run       in java.lang.Thread
|Server running. Browse to http://localhost:8080/Postgresql_Grails_2.3.7

此配置适用于 grails 2.2.4

我必须做些什么才能使其在 grails 2.3.7 下工作?

提前致谢

4

1 回答 1

1

我升级后遇到了同样的问题。这是我的依赖项(jdbc4 而不是 jdbc41):

dependencies {
    runtime 'org.postgresql:postgresql:9.3-1100-jdbc4'
}

而且我不知道这是否是问题所在,但我认为您在休眠之前离开了 '}':

dataSource {
    pooled = true
    driverClassName = "org.postgresql.Driver"
    username = "username"
    password = "password"
}

hibernate {
    cache.use_second_level_cache = true
    cache.use_query_cache = false
    cache.region.factory_class = 'net.sf.ehcache.hibernate.EhCacheRegionFactory'
    singleSession = true 
}
于 2014-04-08T18:56:49.037 回答