I can't figure out what I'm doing wrong here, but the execute method fails,
when providing
the same value as provided in dataSource.setPassword(), with stack trace:
org.h2.jdbc.JdbcSQLNonTransientException: General error:
"org.h2.mvstore.MVStoreException: Store header is corrupt:
C:/tmp/testDB.mv.db [2.1.214/6]" [50000-214]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:554)
at org.h2.message.DbException.getJdbcSQLException(DbException.java:477)
at org.h2.message.DbException.get(DbException.java:212)
at org.h2.message.DbException.convert(DbException.java:395)
at org.h2.message.DbException.toSQLException(DbException.java:367)
at
org.h2.tools.ChangeFileEncryption.execute(ChangeFileEncryption.java:131)
at org.dshops.ib.ds.h2.Main2.main(Main2.java:34)
Caused by: org.h2.mvstore.MVStoreException: Store header is corrupt:
C:/tmp/testDB.mv.db [2.1.214/6]
at org.h2.mvstore.DataUtils.newMVStoreException(DataUtils.java:1004)
at org.h2.mvstore.MVStore.readStoreHeader(MVStore.java:869)
at org.h2.mvstore.MVStore.<init>(MVStore.java:463)
at org.h2.mvstore.MVStore$Builder.open(MVStore.java:4082)
at
org.h2.tools.ChangeFileEncryption.copyMvStore(ChangeFileEncryption.java:202)
at
org.h2.tools.ChangeFileEncryption.process(ChangeFileEncryption.java:183)
at
org.h2.tools.ChangeFileEncryption.process(ChangeFileEncryption.java:175)
at
org.h2.tools.ChangeFileEncryption.execute(ChangeFileEncryption.java:128)
... 1 more
example code attached.
--
You received this message because you are subscribed to the Google Groups "H2
Database" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/h2-database/f6cd3a4a-f51a-4ac1-b70e-6c6e082bbb12n%40googlegroups.com.
package org.dshops.ib.ds.h2;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import org.h2.jdbcx.JdbcDataSource;
import org.h2.tools.ChangeFileEncryption;
import org.h2.tools.Recover;
public class Main2 {
public static void main(String[] args){
try {
String path = "/tmp";
String dbName = "testDB";
String userName = "testUN";
String password = "password";
JdbcDataSource datasource = new JdbcDataSource();
String url = "jdbc:h2:" + path + "\\"+ dbName+";CIPHER=AES";
System.out.println("URL: " + url);
datasource.setURL(url);
datasource.setUser(userName);
String dbPass = userName + " " +password;
System.out.println("DB PASS: " + dbPass);
datasource.setPassword(dbPass);
Connection connection = datasource.getConnection();
connection.close();
System.out.println("-- 1 --");
ChangeFileEncryption.execute(path, dbName, "AES", dbPass.toCharArray(), "foopass".toCharArray(), false);
// we never get here :(
System.out.println("-- 2 --");
Recover.execute(path, dbName);
System.out.println("end");
}
catch (Exception e) {
e.printStackTrace();
}
}
}