A code sample to do that:
-------------------------
Runtime rt = Runtime.getRuntime();
Process p = rt.exec("java -cp h2*.jar org.h2.tools.Server");
For the Spring users -
If you are using a Spring application with H2, you can configure spring to start your H2 server as described in the H2 documentation. Note that this will start the H2 server in the same process as you java application.
You can use java Runtime API in Spring as well. If you want the database to start before Spring/Hibernate are started you can use ServletContextListener to start the H2 server.
No comments:
Post a Comment