I had to recover a corrupted database that was still damaged after using 
the repair tool. the database was so damaged attempts to connect resulted 
in "Connection broken" jdbc exceptions.
repairs would allow connection but inserts in a junit test fell over with 
an IOException.

Anyway, the .data.sql file allow m to reconstruct the database from 
scratch, however it was exactly smooth. Two problems needed fixing to 
succeed:

   - CREATE USER -- fell over because SA always exists in new databases and 
   can't be drop because they are the current user.

 I fixed this by adding IF NOT EXISTS

   - Referential integrity errors -- Data added to in an order that did not 
   respect foreign key dependencies.

 I rearranged the insert commands, so that dependencies were added first

The script was generated by h2 version 1.1.111, if these issues haven't 
addressed yet, I think would be worth considering. 
Trivially adding IF NOT EXISTS to the script generating code.solves one 
problem.
The other problem might be harder, using graph analysis to determine the 
order of inserts taking into account referential integrity contrstaints. 
Alternatively, the script could turn off referential integrity, insert data 
in arbitrary order, then turn referential integrity. Though the second 
option  doesn't catch problems that exist in the reconstructed dataset, I 
doubt that is an overriding concern when trying to recover a database.

-- 
You received this message because you are subscribed to the Google Groups "H2 
Database" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/h2-database/-/TSEUDy-JLlQJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/h2-database?hl=en.

Reply via email to