sagarswathi / h2database

Automatically exported from code.google.com/p/h2database
0 stars 1 forks source link

Opening read-only aes encrypted databases fails since version 1.3.131 #372

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago

What steps will reproduce the problem?
***************************************

Since version 1.3.161, opening a read-only AES-encrypted Database in a zip file 
fails with a NullPointerException (stack trace below). 

The attached code creates an aes encrypted database, puts the db into a zip 
file and tries to open it afterwards.

Works fine with 1.3.160
Fails with 1.3.161 and 1.3.163 

What is the expected output? What do you see instead?
******************************************************
With version 1.6.130:
Create plain db
Copy to zip
Opening inside zip
Finished

With 1.3.161:
Create plain db
Copy to zip
Opening inside zip
Exception in thread "main" org.h2.jdbc.JdbcSQLException: Allgemeiner Fehler: 
"java.lang.NullPointerException"
General error: "java.lang.NullPointerException" [50000-161]
    at org.h2.message.DbException.getJdbcSQLException(DbException.java:329)
    at org.h2.message.DbException.get(DbException.java:158)
    at org.h2.message.DbException.convert(DbException.java:281)
    at org.h2.engine.Database.openDatabase(Database.java:249)
    at org.h2.engine.Database.<init>(Database.java:214)
    at org.h2.engine.Engine.openSession(Engine.java:56)
    at org.h2.engine.Engine.openSession(Engine.java:159)
    at org.h2.engine.Engine.createSessionAndValidate(Engine.java:138)
    at org.h2.engine.Engine.createSession(Engine.java:121)
    at org.h2.engine.Engine.createSession(Engine.java:28)
    at org.h2.engine.SessionRemote.connectEmbeddedOrServer(SessionRemote.java:285)
    at org.h2.jdbc.JdbcConnection.<init>(JdbcConnection.java:110)
    at org.h2.jdbc.JdbcConnection.<init>(JdbcConnection.java:94)
    at org.h2.Driver.connect(Driver.java:72)
    at java.sql.DriverManager.getConnection(Unknown Source)
    at java.sql.DriverManager.getConnection(Unknown Source)
    at bugs.h2zipaes.main(h2zipaes.java:55)
Caused by: java.lang.NullPointerException
    at org.h2.store.fs.FilePath.get(FilePath.java:52)
    at org.h2.store.fs.FileUtils.newDirectoryStream(FileUtils.java:140)
    at org.h2.engine.Database.deleteOldTempFiles(Database.java:1480)
    at org.h2.engine.Database.open(Database.java:549)
    at org.h2.engine.Database.openDatabase(Database.java:219)
    ... 13 more

What version of the product are you using? On what operating system, file
system, and virtual machine?

$ java -version
java version "1.6.0_26"
Java(TM) SE Runtime Environment (build 1.6.0_26-b03)
Java HotSpot(TM) 64-Bit Server VM (build 20.1-b02, mixed mode)

Operating System is Windows 7

Do you know a workaround?

=> No (Putting the database outside the zip file is not an option for us) 

Best regards,
Lars

Original issue reported on code.google.com by lars.bru...@virtualforge.com on 11 Jan 2012 at 10:56

GoogleCodeExporter commented 8 years ago
Sorry for the typo in the issue title, should be "...fails since version 
1.3.161"

Original comment by lars.bru...@virtualforge.com on 11 Jan 2012 at 10:59

GoogleCodeExporter commented 8 years ago
I will have a look.

Original comment by thomas.t...@gmail.com on 30 Jan 2012 at 6:33

GoogleCodeExporter commented 8 years ago
Hi,

It works for me if a slash is added after the "!". See also 
http://h2database.com/html/features.html#database_in_zip

           String databaseZipUrl = "jdbc:h2:zip:/Users/thomasm/temp/test.zip!/testdb;IFEXISTS=TRUE;ACCESS_MODE_DATA=r;CIPHER=AES";

instead of
           String databaseZipUrl = "jdbc:h2:zip:/Users/thomasm/temp/test.zip!testdb;IFEXISTS=TRUE;ACCESS_MODE_DATA=r;CIPHER=AES";

Original comment by thomas.t...@gmail.com on 23 Feb 2012 at 7:43