How to open split .h2 database using java -cp option

453 views
Skip to first unread message

Vineet

unread,
Aug 12, 2014, 3:56:08 AM8/12/14
to h2-da...@googlegroups.com
Hi All,


I have two db files x.h2(more than 1 GB) and x.h2.1.part (nearly 350 MB) created from my product line. I need to open the database.
I am doing this by 
java -jar "jar file" and then the path to the 'x' database file. It gives me error saying corrupted file (File corrupted while reading record: "571899 of 524288". Possible solution: use the recovery tool [90030-174] 90030/90030 (Help)). I don't think this is corrupted as i have checked the checksum of files while copying.

I tried opening it with java -cp option and getting the same error, mentioned below.

Is there any way to open the db files keeping in mind we have two split files? Any help is highly appreciated.

Exception in thread "main" org.h2.jdbc.JdbcSQLException: File corrupted while reading record: "571899 of 524288"
. Possible solution: use the recovery tool [90030-174]
        at org.h2.message.DbException.getJdbcSQLException(DbException.java:332)
        at org.h2.message.DbException.get(DbException.java:172)
        at org.h2.message.DbException.get(DbException.java:149)
        at org.h2.store.PageStore.readPage(PageStore.java:1288)
        at org.h2.store.PageStore.getPage(PageStore.java:738)
        at org.h2.index.PageDataIndex.getPage(PageDataIndex.java:232)
        at org.h2.index.PageDataNode.getLastKey(PageDataNode.java:213)
        at org.h2.index.PageDataIndex.<init>(PageDataIndex.java:87)
        at org.h2.table.RegularTable.<init>(RegularTable.java:84)
        at org.h2.store.PageStore.openMetaIndex(PageStore.java:1570)
        at org.h2.store.PageStore.recover(PageStore.java:1369)
        at org.h2.store.PageStore.openExisting(PageStore.java:361)
        at org.h2.store.PageStore.open(PageStore.java:285)
        at org.h2.engine.Database.getPageStore(Database.java:2277)
        at org.h2.engine.Database.open(Database.java:610)
        at org.h2.engine.Database.openDatabase(Database.java:236)
        at org.h2.engine.Database.<init>(Database.java:231)
        at org.h2.engine.Engine.openSession(Engine.java:56)
        at org.h2.engine.Engine.openSession(Engine.java:160)
        at org.h2.engine.Engine.createSessionAndValidate(Engine.java:139)
        at org.h2.engine.Engine.createSession(Engine.java:122)
        at org.h2.engine.Engine.createSession(Engine.java:28)
        at org.h2.engine.SessionRemote.connectEmbeddedOrServer(SessionRemote.java:323)
        at org.h2.jdbc.JdbcConnection.<init>(JdbcConnection.java:105)
        at org.h2.jdbc.JdbcConnection.<init>(JdbcConnection.java:90)
        at org.h2.Driver.connect(Driver.java:73)
        at java.sql.DriverManager.getConnection(Unknown Source)
        at java.sql.DriverManager.getConnection(Unknown Source)
        at org.h2.tools.RunScript.process(RunScript.java:314)
        at org.h2.tools.RunScript.runTool(RunScript.java:142)
        at org.h2.tools.RunScript.main(RunScript.java:69)

Thanks in advance,
Vineet

Noel Grandin

unread,
Aug 12, 2014, 4:13:54 AM8/12/14
to h2-da...@googlegroups.com
You have to pass a specially formatted URL to H2 in order to use file splitting.

What exact command line are you using?

Vineet

unread,
Aug 12, 2014, 7:02:12 AM8/12/14
to h2-da...@googlegroups.com

java -jar "C:\SA\SACE\SACE-626\7th Aug\h2-1.3.174.jar"

it open a UI for connecting to database where in 
driver class entry has 'org.h2.Driver' value
JDBC URL: jdbc:h2:<path to the h2 database>
username: sa
password


If this one will not work. Please let me know what else i can try to open this DB?

Thanks

Vineet

unread,
Aug 12, 2014, 7:49:04 AM8/12/14
to h2-da...@googlegroups.com
for JDBC URL: jdbc:h2:<path to the h2 database>

i am giving path to till the x.h2 database.

Vineet

Noel Grandin

unread,
Aug 12, 2014, 7:50:22 AM8/12/14
to h2-da...@googlegroups.com
That URL will not work. You have to same URL that was used to create the split database file.

Vineet

unread,
Aug 12, 2014, 12:05:19 PM8/12/14
to h2-da...@googlegroups.com
Can you provide me the steps to connect to split database?
I have limited knowledge on this.

Thanks,
Vineet

Pavel Goloborodko

unread,
Aug 12, 2014, 2:41:50 PM8/12/14
to h2-da...@googlegroups.com


--
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 h2-database...@googlegroups.com.
To post to this group, send email to h2-da...@googlegroups.com.
Visit this group at http://groups.google.com/group/h2-database.
For more options, visit https://groups.google.com/d/optout.



--
С уважением, / Kind regards,
Павел Голобородько / Pavel Goloborodko

Vineet

unread,
Aug 14, 2014, 12:45:12 AM8/14/14
to h2-da...@googlegroups.com
Thanks every one for replying on this thread. I think I found what I need to do:
You should be knowing the split size of the DB you are dealing with.

for example if your split size of your DB is 1GB then the URL you need is jdbc:h2:split:30:<path to database>

Thanks

Vineet

unread,
Aug 14, 2014, 12:46:04 AM8/14/14
to h2-da...@googlegroups.com
Forgot to mention,
30 is the split size and that can vary.

Thomas Mueller

unread,
Aug 15, 2014, 5:33:38 AM8/15/14
to H2 Google Group
Hi,

See also the documentation of the split file system at http://h2database.com/html/advanced.html#file_system_split

Regards,
Thomas


--
Reply all
Reply to author
Forward
0 new messages