【发布时间】:2017-06-08 07:42:47
【问题描述】:
我有一个 Grails 3 项目,在 Intellij 中有多个数据源。尝试运行 Grails 命令:
schema-export --filename grails-app/conf/db/migration/operator/ddl.sql --datasource=operator
org.h2.jdbc.JdbcSQLException: 用户名或密码错误 [28000-194]
完整的错误如下。有趣的是,连接不是到 h2 DB。 application.yml 正在使用 PostgreSQL 数据库。
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
为什么会失败?
在“开发”环境中为 .\build\ddl.sql 生成脚本 数据源“操作员”2017-06-08 14:35:14.598 错误 --- [
Thread-13] o.g.p.d.EmbeddedDatabaseShutdownHook:错误关闭 关闭数据源org.h2.jdbc.JdbcSQLException:用户名或密码错误 [28000-194] 在 org.h2.message.DbException.getJdbcSQLException(DbException.java:345) 在 org.h2.message.DbException.get(DbException.java:179) 在 org.h2.message.DbException.get(DbException.java:155) 在 org.h2.message.DbException.get(DbException.java:144) 在 org.h2.engine.Engine.validateUserAndPassword(Engine.java:336) 在 org.h2.engine.Engine.createSessionAndValidate(Engine.java:162) 在 org.h2.engine.Engine.createSession(Engine.java:137) 在 org.h2.engine.Engine.createSession(Engine.java:27) 在 org.h2.engine.SessionRemote.connectEmbeddedOrServer(SessionRemote.java:354) 在 org.h2.jdbc.JdbcConnection.(JdbcConnection.java:116) 在 org.h2.jdbc.JdbcConnection.(JdbcConnection.java:100) 在 org.h2.Driver.connect(Driver.java:69) 在 java.sql.DriverManager.getConnection(DriverManager.java:664) 在 java.sql.DriverManager.getConnection(DriverManager.java:208) 在 org.springframework.jdbc.datasource.DriverManagerDataSource.getConnectionFromDriverManager(DriverManagerDataSource.java:153) 在 org.springframework.jdbc.datasource.DriverManagerDataSource.getConnectionFromDriver(DriverManagerDataSource.java:144) 在 org.springframework.jdbc.datasource.AbstractDriverBasedDataSource.getConnectionFromDriver(AbstractDriverBasedDataSource.java:196) 在 org.springframework.jdbc.datasource.AbstractDriverBasedDataSource.getConnection(AbstractDriverBasedDataSource.java:159) 在 org.grails.plugins.datasource.EmbeddedDatabaseShutdownHook.shutdownEmbeddedDatabase(EmbeddedDatabaseShutdownHook.groovy:87) 在 sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 在 sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 在 sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 在 java.lang.reflect.Method.invoke(Method.java:498) 在 org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1426) 在 org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93) 在 groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325) 在 groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1218) 在 groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1027) 在 org.codehaus.groovy.runtime.InvokerHelper.invokePogoMethod(InvokerHelper.java:925) 在 org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:908) 在 org.codehaus.groovy.runtime.InvokerHelper.invokeMethodSafe(InvokerHelper.java:76) 在 org.grails.plugins.datasource.EmbeddedDatabaseShutdownHook$_stop_closure2.doCall(EmbeddedDatabaseShutdownHook.groovy:39) 在 sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 在 sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 在 sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 在 java.lang.reflect.Method.invoke(Method.java:498) 在 org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1426) 在 org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93) 在 groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325) 在 org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:294) 在 groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1027) 在 groovy.lang.Closure.call(Closure.java:414) 在 groovy.lang.Closure.call(Closure.java:430) 在 org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:2030) 在 org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:2015) 在 org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:2056) 在 org.grails.plugins.datasource.EmbeddedDatabaseShutdownHook.stop(EmbeddedDatabaseShutdownHook.groovy:38) 在 org.grails.plugins.datasource.EmbeddedDatabaseShutdownHook.stop(EmbeddedDatabaseShutdownHook.groovy:62) 在 org.springframework.context.support.DefaultLifecycleProcessor.doStop(DefaultLifecycleProcessor.java:231) 在 org.springframework.context.support.DefaultLifecycleProcessor.access$300(DefaultLifecycleProcessor.java:50) 在 org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.stop(DefaultLifecycleProcessor.java:365) 在 org.springframework.context.support.DefaultLifecycleProcessor.stopBeans(DefaultLifecycleProcessor.java:204) 在 org.springframework.context.support.DefaultLifecycleProcessor.onClose(DefaultLifecycleProcessor.java:120) 在 org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1002) 在 org.springframework.context.support.AbstractApplicationContext$2.run(AbstractApplicationContext.java:928)
【问题讨论】:
标签: grails schemaexport