Search code examples
javadatabasetestngh2in-memory-database

How to create H2 in-memory database using H2 embedded database


I'm currently writing some test cases using testng. I have a requirement to repeat same test set in H2 embedded db and in H2 in-memory db. What i want is to copy all tables and data from H2 embedded db to H2 in-memory db upon transition from one db type to another. Is it possible ? thanks in advance.


Solution

  • you could use the script tool from here

    http://h2database.com/javadoc/org/h2/tools/Script.html

    to export the tables and data and then use runscript as descibed here

    http://h2database.com/html/grammar.html#runscript

    to import it in the other db