Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Method to restore database of H2 programmatically / in sql
public Boolean restore(String filename, TimeUnit timeUnit, Integer during) {
Path restoreFile = backup.getLocation().resolve(filename);
if (!Files.exists(restoreFile))
return Boolean.FALSE;"Full database reset");
em.createNativeQuery("DROP ALL OBJECTS;").executeUpdate(); -> timeUnit.sleep(during));"Full database restore");
em.createNativeQuery("RUNSCRIPT FROM '"+ restoreFile.toAbsolutePath().toString() +"'").executeUpdate();
return Boolean.TRUE;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment