MuleSoft and in-memory DB H2 integration
Note: Database Config in the project shows ${app.home}/h2db/mule as the path for the file. Before pointing to this path, H2 db file mule.mv.db needs to be created locally first. Follow these steps.
- Create a folder on your local drive with the name h2db. Say for instance path to it is: C:/h2db
- Modify the URL in Database Config (H2_Db_Config in global.xml) to: jdbc:h2:file:C:/h2db/mule where mule is the actual DB filename (like instance name)
- Run the project, and execute /ddl endpoint. Upon successful run, it should create a file mule.mv.db within the folder C:/h2db
- In your proect workspace, under /src/main/resources, create a folder with the name h2db
- Copy the mule.mv.db file form C:/h2db to the folder /src/main/resources/h2db
- Then you are ready to modify the URL in Database Config (H2_Db_Config in global.xml) back to: ${app.home}/h2db/mule
- Run the Munit tests to make sure all tests pass
You can view the actual H2 DB in a web console by running this java command from the folder having the h2-1.4.200.jar : java -cp h2-1.4.200.jar org.h2.tools.Server -web (jar file can be found in Project Libraries of the workspace). It will open H2 Console like shown below:
Once you click Connect, it will show the DB like shown below: