2

In my BuildConfig.groovy

I have :

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

In my DataSource.groovy

I have :

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"
        }

    }
}
}

Here are the error message

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

This configuration works for grails 2.2.4

What I have to do to make it work under grails 2.3.7?

Thanks in advance

user3511317
  • 23
  • 1
  • 3
  • 1
    `grails clean` is required after changes. Somehow your old datasource is being referred which is pointed to in-memory h2 db. – dmahapatro Apr 08 '14 at 14:24

1 Answers1

1

I had the same problem after my upgrade. This is my dependencies (jdbc4 and not jdbc41):

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

And I don't know if it is the problem, but I think you left '}' before hibernate:

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 
}
Abincepto
  • 1,016
  • 8
  • 13
  • Yes, you are right, if I put runtime 'org.postgresql:postgresql:9.3-1100-jdbc4', it works , I've done a little research. The postgresql-jdbc jar which we use for connecting the dataSource server depends on the java version. For instance : For java 6 use: postgresql-9.2-1004-jdbc4.jar postgresql-9.3-1100-jdbc4.jar For java 7 use: postgresql-9.2-1004-jdbc41.jar postgresql-9.3-1100-jdbc41.jar If we don't have the right version of the jar. We will have the following problems: – user3511317 Apr 14 '14 at 12:29