This blog will guide you through the process of opening the web based database console for the H2 database.
By default, all CAP applications persist their data to an in-memory relational database during development. For CAP Java the default development database is H2. It is automatically added to your projects configuration:
Please make sure that the above dependency is part of your configuration. Otherwise this article does not apply to you. 😉
The auto-configuration run during the application's startup is taking care of bootstrapping the in-memory database. This also provides an additional web end point with an administration console where you can introspect and also interact with the database.
So, CAP Java applications configured with the H2 database will expose this administration console under the url http://localhost:8080/h2-console (if your port differs from the default you need to adapt it here). Once you have opened the URL you will see this login screen:
In most of the cases the credentials and especially the JDBC Url will already be prefilled with the correct values. If you hit the "Test Connection" button and a green box with "Test successful" appears you're good to go. If the box is red with some error message, the JDBC url does not reflect the url of the running CAP Java application anymore (this can happen with restarts or application context refreshes). In such cases you need to copy the latest H2 JDBC url from the application's console log and paste it to the JDBC url input of the H2 console login screen.
Once you have passed the H2 console's login screen you can start to explore your CAP Java application's database schema. Enjoy browsing the catalog or executing arbitrary SQL commands. 😎
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.