0
votes

I have a Grails 3 project with multiple data sources in Intellij. Try to run the Grails command:

schema-export  --filename grails-app/conf/db/migration/operator/ddl.sql  --datasource=operator

org.h2.jdbc.JdbcSQLException: Wrong user name or password [28000-194]

The full error is below. Interestingly, the connection is not to an h2 DB. application.yml is using a PostgreSQL DB.

dataSources:
  dataSource:
    pooled: false
    jmxExport: true
    driverClassName: org.postgresql.Driver
    username: user1
    password: password1
    dialect: net.kaleidos.hibernate.PostgresqlExtensionsDialect
  operator:
    pooled: false
    jmxExport: true
    driverClassName: org.postgresql.Driver
    username: user2
    password: password2
    dialect: org.hibernate.dialect.PostgresqlExtensionsDialect

environments:
  development:
    server:
        contextPath: '/@info.app.name@'
    dataSource:
        dbCreate: none
        url: jdbc:postgresql://localhost:5432/mydb?currentSchema=schema1
    datasources:
        operator:
            dbCreate: none
            url: jdbc:postgresql://localhost1:5432/mydb?currentSchema=schema2

Why is this failing?

Generating script to .\build\ddl.sql in environment 'development' for DataSource 'operator' 2017-06-08 14:35:14.598 ERROR --- [
Thread-13] o.g.p.d.EmbeddedDatabaseShutdownHook : Error shutting down datasource

org.h2.jdbc.JdbcSQLException: Wrong user name or password [28000-194] at org.h2.message.DbException.getJdbcSQLException(DbException.java:345) at org.h2.message.DbException.get(DbException.java:179) at org.h2.message.DbException.get(DbException.java:155) at org.h2.message.DbException.get(DbException.java:144) at org.h2.engine.Engine.validateUserAndPassword(Engine.java:336) at org.h2.engine.Engine.createSessionAndValidate(Engine.java:162) at org.h2.engine.Engine.createSession(Engine.java:137) at org.h2.engine.Engine.createSession(Engine.java:27) at org.h2.engine.SessionRemote.connectEmbeddedOrServer(SessionRemote.java:354) at org.h2.jdbc.JdbcConnection.(JdbcConnection.java:116) at org.h2.jdbc.JdbcConnection.(JdbcConnection.java:100) at org.h2.Driver.connect(Driver.java:69) at java.sql.DriverManager.getConnection(DriverManager.java:664) at java.sql.DriverManager.getConnection(DriverManager.java:208) at org.springframework.jdbc.datasource.DriverManagerDataSource.getConnectionFromDriverManager(DriverManagerDataSource.java:153) at org.springframework.jdbc.datasource.DriverManagerDataSource.getConnectionFromDriver(DriverManagerDataSource.java:144) at org.springframework.jdbc.datasource.AbstractDriverBasedDataSource.getConnectionFromDriver(AbstractDriverBasedDataSource.java:196) at org.springframework.jdbc.datasource.AbstractDriverBasedDataSource.getConnection(AbstractDriverBasedDataSource.java:159) at org.grails.plugins.datasource.EmbeddedDatabaseShutdownHook.shutdownEmbeddedDatabase(EmbeddedDatabaseShutdownHook.groovy:87) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1426) at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93) at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1218) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1027) at org.codehaus.groovy.runtime.InvokerHelper.invokePogoMethod(InvokerHelper.java:925) at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:908) at org.codehaus.groovy.runtime.InvokerHelper.invokeMethodSafe(InvokerHelper.java:76) at org.grails.plugins.datasource.EmbeddedDatabaseShutdownHook$_stop_closure2.doCall(EmbeddedDatabaseShutdownHook.groovy:39) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1426) at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93) at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325) at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:294) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1027) at groovy.lang.Closure.call(Closure.java:414) at groovy.lang.Closure.call(Closure.java:430) at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:2030) at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:2015) at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:2056) at org.grails.plugins.datasource.EmbeddedDatabaseShutdownHook.stop(EmbeddedDatabaseShutdownHook.groovy:38) at org.grails.plugins.datasource.EmbeddedDatabaseShutdownHook.stop(EmbeddedDatabaseShutdownHook.groovy:62) at org.springframework.context.support.DefaultLifecycleProcessor.doStop(DefaultLifecycleProcessor.java:231) at org.springframework.context.support.DefaultLifecycleProcessor.access$300(DefaultLifecycleProcessor.java:50) at org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.stop(DefaultLifecycleProcessor.java:365) at org.springframework.context.support.DefaultLifecycleProcessor.stopBeans(DefaultLifecycleProcessor.java:204) at org.springframework.context.support.DefaultLifecycleProcessor.onClose(DefaultLifecycleProcessor.java:120) at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1002) at org.springframework.context.support.AbstractApplicationContext$2.run(AbstractApplicationContext.java:928)

1

1 Answers

0
votes

I partly solved this. The Grails 3 documentation for configuring multiple data sources appears to be wrong. http://docs.grails.org/latest/guide/conf.html#multipleDatasources It doesn't appear to work for the per-environment configuration in application.yml. By putting all the configuration parameters at the root level the export-schema command runs.

Which answers the question I asked here, but the schema-export still doesn't work:

  • It creates build\ddl.sql (the gradle schemaExport default), not the one specified on the schema-export grails command

  • build/ddl.sql is empty.