【问题标题】:Unable to create an encrypted H2 database for Grails无法为 Grails 创建加密的 H2 数据库
【发布时间】:2012-09-26 18:58:50
【问题描述】:

我有一个 grails 项目,我需要在其中创建一个加密的 H2 数据库,但我不确定如何使它工作。这是我在 DataSource.groovy 中的内容:

dataSource {
    pooled = true
    driverClassName = "org.h2.Driver"
    dialect = "org.hibernate.dialect.H2Dialect"
    dbCreate = "update" // one of 'create', 'create-drop','update'
    url = "jdbc:h2:/opt/viewpoint/data/h2/viewpoint;MODE=MYSQL;CIPHER=AES"
    user = "sa"
    pwds = "filepwd password"
}

当我运行它时,我得到以下信息:

Caused by: org.h2.jdbc.JdbcSQLException: Wrong password format, must be: file password <space> user password [90050-117]
    at org.h2.message.Message.getSQLException(Message.java:105)
    at org.h2.message.Message.getSQLException(Message.java:116)
    at org.h2.message.Message.getSQLException(Message.java:75)
    at org.h2.message.Message.getSQLException(Message.java:151)
    at org.h2.engine.ConnectionInfo.convertPasswords(ConnectionInfo.java:264)
    at org.h2.engine.ConnectionInfo.<init>(ConnectionInfo.java:72)
    at org.h2.jdbc.JdbcConnection.<init>(JdbcConnection.java:94)
    at org.h2.Driver.connect(Driver.java:58)
    at java.sql.DriverManager.getConnection(DriverManager.java:582)
    at java.sql.DriverManager.getConnection(DriverManager.java:154)
    at $Proxy46.getMetaData(Unknown Source)
    ... 23 more

【问题讨论】:

  • 你想加密数据库还是密码?
  • pwds = "filepwd 密码" 是干什么用的?
  • @bluesman,我想加密数据库。
  • @MBozic, pwds 用于指定密码。第一个用于加密数据库文件,第二个用于访问数据库。
  • 您应该使用更新版本的 H2。你用的那个很旧了。

标签: grails encryption passwords h2


【解决方案1】:

我不确定您的数据源配置示例来自哪里,但您需要使用 usernamepassword 而不是 userpwds

dataSource {
  pooled = true
  // ...
  username = "sa"
  password = "filepwd password"
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-07-25
    • 2019-01-14
    • 2021-10-30
    • 1970-01-01
    • 1970-01-01
    • 2013-01-31
    • 2020-08-12
    相关资源
    最近更新 更多