#H2 database how to#That’s all on How to integrate H2 database in Spring boot app. The H2 database is preinstalled with the Cram software. A browser-based console application is included. To disconnect h2 database, click on the following icon on extreme left of the H2 Console and it will land you back to the screen in step 6.īy clicking on this icon, we are just disconnecting from the database, however, h2 console server is still up and running.so we can again click on connect and connect to the database. H2 is an SQL database engine that is written in Java that implements the JDBC API. Now click on connect button and you will see that database connection with h2 DB is established. Now click on Test Connection button and you can see that connection is successful as can be seen in below screenshot : Now if you hit the following Url, you can see that H2 web console is up and running and you can connect to H2 database. The reason we are getting above error page is that we have not told Spring boot to enable the web console of h2 database and map /h2.we can do that by making following entry in the application.properties file Hit the following Url to open web console of h2 This will start embedded Tomcat Server as well and deploy the application on Tomcat.Īs you can see in the logs that Tomcat started on port 8080 and SprigBootAndH2DbIntegrationApplicaiton started successfully. Open springBootAndH2DbIntegrationApplicaiton.java and run it as Java application. As h2 jar will be there on the classpath, Spring boot automatically creates a data source to connect to h2 database. Note: We are adding the h2 dependency to connect with H2 in-memory database. Open the pom.xml and it will have following entry for H2 database Import the extracted folder in eclipse as existing Maven Project. #H2 database zip#It will download a zip with name springBootAndH2DbIntegration on your local drive. Step 1įill the Group, artifactId, and dependencies(web and H2) and click on Generate Project button. Integrating the H2 Database with Spring Boot is like a cakewalk. We are going to create a springboot application with H2 Database. How to integrate the H2 Database with Spring Boot? The main features of H2 are: Very fast, open source, JDBC API Embedded and server modes in-memory databases Browser based Console application Small footprint: around 2.5 MB jar file size 2) Setup. Say, we want to do some POC(Proof of concept) before starting a project or we are working on prototype, in such case scenario,it will not be ideal to set up an actual database, as it will involve a lot of effort and cost for having a database server, Installing database, creating schemas, tables etc.So in such scenarios we use in memory database like h2. As we are using h2 in embedded mode(h2 jar is part of our application), so once our application is up and running,h2 console server will also be up and from there we can connect to h2 database. So basically, it is a client/server application.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |