2

I have a grails project where I need to create an encrypted H2 database, but I'm not sure how to make it work. Here is what I have in 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"
}

When I run it, I get the following:

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
wholladay
  • 1,400
  • 1
  • 18
  • 34

1 Answers1

3

I'm not sure where you got your datasource configuration example from, but you need to use username and password instead of user and pwds:

dataSource {
  pooled = true
  // ...
  username = "sa"
  password = "filepwd password"
}
Ian Roberts
  • 120,891
  • 16
  • 170
  • 183