{"id":83911,"date":"2018-11-26T13:00:24","date_gmt":"2018-11-26T11:00:24","guid":{"rendered":"https:\/\/www.javacodegeeks.com\/?p=83911"},"modified":"2018-11-25T16:09:17","modified_gmt":"2018-11-25T14:09:17","slug":"understandin-inmemory-database-spring","status":"publish","type":"post","link":"https:\/\/www.javacodegeeks.com\/2018\/11\/understandin-inmemory-database-spring.html","title":{"rendered":"Understanding H2 InMemory Database with Spring Boot"},"content":{"rendered":"<h2>Introduction<\/h2>\n<p>Basically the database setup involves several steps before we can use it through configured datasource in our application. This actually is required in case of actual project implementations. However, there are situations where we just need a POC to be done for something, and the whole database setup thing still becomes an obligation. Similarly, for unit tests, it would be ideal to have our own set of records in the database, so its independent, without getting impacted by the data changes in the deployed environment. For such use cases, in-memory databases are the ideal solution.<\/p>\n<blockquote>\n<p>An\u00a0<strong>in-memory database<\/strong> gets created when the application starts, while it gets destroyed when the application stops.<\/p>\n<\/blockquote>\n<p>Spring Boot integrates H2 database with lot of ease. So you can easily and quickly switch between a real database and an in-memory database.<\/p>\n<blockquote>\n<p>Note that, H2 InMemory Database is a relational DBMS written in Java.<\/p>\n<\/blockquote>\n<p>Let\u2019s check out a quick demo.<\/p>\n<h2>Implementation<\/h2>\n<p>Lets generate the Spring Boot project from <a href=\"https:\/\/start.spring.io\/\" target=\"_blank\" rel=\"noopener\">Spring initializr<\/a>. Ensure you add Web, JPA, H2 and DevTools dependencies as shown below.<\/p>\n<p><a href=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/11\/1.png\"><img decoding=\"async\" class=\"aligncenter wp-image-83915 size-large\" src=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/11\/1-1024x431.png\" alt=\"H2 InMemory Database\" width=\"620\" height=\"261\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/11\/1-1024x431.png 1024w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/11\/1-300x126.png 300w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/11\/1-768x323.png 768w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/11\/1.png 1192w\" sizes=\"(max-width: 620px) 100vw, 620px\" \/><\/a><\/p>\n<p>Let\u2019s look at the generated pom file.<\/p>\n<p><em>pom.xml<\/em><\/p>\n<pre class=\"brush:xml; wrap-lines:false\">&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\r\n&lt;project xmlns=\"http:\/\/maven.apache.org\/POM\/4.0.0\"\r\n\txmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\"\r\n\txsi:schemaLocation=\"http:\/\/maven.apache.org\/POM\/4.0.0 http:\/\/maven.apache.org\/xsd\/maven-4.0.0.xsd\"&gt;\r\n\t&lt;modelVersion&gt;4.0.0&lt;\/modelVersion&gt;\r\n \r\n\t&lt;groupId&gt;com.jcombat&lt;\/groupId&gt;\r\n\t&lt;artifactId&gt;h2demo&lt;\/artifactId&gt;\r\n\t&lt;version&gt;0.0.1-SNAPSHOT&lt;\/version&gt;\r\n\t&lt;packaging&gt;jar&lt;\/packaging&gt;\r\n \r\n\t&lt;name&gt;h2demo&lt;\/name&gt;\r\n\t&lt;description&gt;Demo project for Spring Boot&lt;\/description&gt;\r\n \r\n\t&lt;parent&gt;\r\n\t\t&lt;groupId&gt;org.springframework.boot&lt;\/groupId&gt;\r\n\t\t&lt;artifactId&gt;spring-boot-starter-parent&lt;\/artifactId&gt;\r\n\t\t&lt;version&gt;2.1.0.RELEASE&lt;\/version&gt;\r\n\t\t&lt;relativePath \/&gt; &lt;!-- lookup parent from repository --&gt;\r\n\t&lt;\/parent&gt;\r\n \r\n\t&lt;properties&gt;\r\n\t\t&lt;project.build.sourceEncoding&gt;UTF-8&lt;\/project.build.sourceEncoding&gt;\r\n\t\t&lt;project.reporting.outputEncoding&gt;UTF-8&lt;\/project.reporting.outputEncoding&gt;\r\n\t\t&lt;java.version&gt;1.8&lt;\/java.version&gt;\r\n\t&lt;\/properties&gt;\r\n \r\n\t&lt;dependencies&gt;\r\n\t\t&lt;dependency&gt;\r\n\t\t\t&lt;groupId&gt;org.springframework.boot&lt;\/groupId&gt;\r\n\t\t\t&lt;artifactId&gt;spring-boot-starter-data-jpa&lt;\/artifactId&gt;\r\n\t\t&lt;\/dependency&gt;\r\n\t\t&lt;dependency&gt;\r\n\t\t\t&lt;groupId&gt;org.springframework.boot&lt;\/groupId&gt;\r\n\t\t\t&lt;artifactId&gt;spring-boot-starter-web&lt;\/artifactId&gt;\r\n\t\t&lt;\/dependency&gt;\r\n \r\n\t\t&lt;dependency&gt;\r\n\t\t\t&lt;groupId&gt;org.springframework.boot&lt;\/groupId&gt;\r\n\t\t\t&lt;artifactId&gt;spring-boot-devtools&lt;\/artifactId&gt;\r\n\t\t\t&lt;scope&gt;runtime&lt;\/scope&gt;\r\n\t\t&lt;\/dependency&gt;\r\n\t\t&lt;dependency&gt;\r\n\t\t\t&lt;groupId&gt;com.h2database&lt;\/groupId&gt;\r\n\t\t\t&lt;artifactId&gt;h2&lt;\/artifactId&gt;\r\n\t\t\t&lt;scope&gt;runtime&lt;\/scope&gt;\r\n\t\t&lt;\/dependency&gt;\r\n\t\t&lt;dependency&gt;\r\n\t\t\t&lt;groupId&gt;org.springframework.boot&lt;\/groupId&gt;\r\n\t\t\t&lt;artifactId&gt;spring-boot-starter-test&lt;\/artifactId&gt;\r\n\t\t\t&lt;scope&gt;test&lt;\/scope&gt;\r\n\t\t&lt;\/dependency&gt;\r\n\t&lt;\/dependencies&gt;\r\n \r\n\t&lt;build&gt;\r\n\t\t&lt;plugins&gt;\r\n\t\t\t&lt;plugin&gt;\r\n\t\t\t\t&lt;groupId&gt;org.springframework.boot&lt;\/groupId&gt;\r\n\t\t\t\t&lt;artifactId&gt;spring-boot-maven-plugin&lt;\/artifactId&gt;\r\n\t\t\t&lt;\/plugin&gt;\r\n\t\t&lt;\/plugins&gt;\r\n\t&lt;\/build&gt;\r\n \r\n&lt;\/project&gt;<\/pre>\n<p>We also notice application.properties file generated as \u2013<div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<p><em>application.properties<\/em><\/p>\n<pre class=\"brush:java\"># H2\r\nspring.h2.console.enabled=true\r\nspring.h2.console.path=\/h2\r\n \r\n# Datasource\r\nspring.datasource.url=jdbc:h2:mem:testdb\r\nspring.datasource.username=sa\r\nspring.datasource.password=\r\nspring.datasource.driver-class-name=org.h2.Driver<\/pre>\n<p>The property\u00a0<strong>spring.h2.console.enabled=true<\/strong> enables the web console at\u00a0http:\/\/localhost:8080\/h2<\/p>\n<p><a href=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/11\/H2-Web-Console.png\"><img decoding=\"async\" class=\"aligncenter wp-image-83917 size-full\" src=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/11\/H2-Web-Console.png\" alt=\"H2 InMemory Database\" width=\"432\" height=\"334\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/11\/H2-Web-Console.png 432w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/11\/H2-Web-Console-300x232.png 300w\" sizes=\"(max-width: 432px) 100vw, 432px\" \/><\/a><\/p>\n<p>Click on Connect and you get into the page where you see available tables in the DB.<\/p>\n<p><a href=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/11\/Autogenerated-table.png\"><img decoding=\"async\" class=\"aligncenter wp-image-83918 size-full\" src=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/11\/Autogenerated-table.png\" alt=\"H2 InMemory Database\" width=\"759\" height=\"154\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/11\/Autogenerated-table.png 759w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/11\/Autogenerated-table-300x61.png 300w\" sizes=\"(max-width: 759px) 100vw, 759px\" \/><\/a><\/p>\n<p>You might be wondering, how come Student table got created. The magic happens with <strong>data.sql<\/strong> placed at src\/main\/resources. Just ensure you have the insert statements in the <strong>data.sql<\/strong> file as mentioned below \u2013<\/p>\n<p><em>data.sql<\/em><\/p>\n<pre class=\"brush:sql\">insert into STUDENT\r\nvalues(10001,'Ajay', 'AAA1');\r\n \r\ninsert into STUDENT\r\nvalues(10002,'Ajit', 'AAA2');<\/pre>\n<p>Spring Boot Auto Configuration checks the values in the <strong>data.sql<\/strong> file and does the needful for you, i.e. creates the STUDENT table, and executes the insert statements. Smart!<\/p>\n<p>Lets check out how we can operate on these student records.<\/p>\n<p>To do that, let\u2019s have the Student entity class created now.<\/p>\n<p><em>Student.java<\/em><\/p>\n<pre class=\"brush:java\">package com.jcombat.entity;\r\n \r\nimport javax.persistence.Entity;\r\nimport javax.persistence.GeneratedValue;\r\nimport javax.persistence.Id;\r\n \r\n@Entity\r\npublic class Student {\r\n \r\n\t@Id\r\n\t@GeneratedValue\r\n\tprivate Long id;\r\n\tprivate String name;\r\n\tprivate String section;\r\n \r\n\tpublic Student() {\r\n\t}\r\n \r\n\tpublic Student(Long id, String name, String section) {\r\n\t\tthis.id = id;\r\n\t\tthis.name = name;\r\n\t\tthis.section = section;\r\n\t}\r\n \r\n\tpublic Long getId() {\r\n\t\treturn id;\r\n\t}\r\n \r\n\tpublic void setId(Long id) {\r\n\t\tthis.id = id;\r\n\t}\r\n \r\n\tpublic String getName() {\r\n\t\treturn name;\r\n\t}\r\n \r\n\tpublic void setName(String name) {\r\n\t\tthis.name = name;\r\n\t}\r\n \r\n\tpublic String getSection() {\r\n\t\treturn section;\r\n\t}\r\n \r\n\tpublic void setSection(String section) {\r\n\t\tthis.section = section;\r\n\t}\r\n \r\n}<\/pre>\n<p>To access the database, let\u2019s write a simple JPA interface which provides the required helper functions to do basic DB operations.<\/p>\n<p><em>StudentRepository.java<\/em><\/p>\n<pre class=\"brush:java\">package com.jcombat.repository;\r\n \r\nimport org.springframework.data.jpa.repository.JpaRepository;\r\nimport org.springframework.stereotype.Repository;\r\n \r\nimport com.jcombat.entity.Student;\r\n \r\n@Repository\r\npublic interface StudentRepository extends JpaRepository&lt;Student, Long&gt; {\r\n \r\n}<\/pre>\n<p>Let\u2019s now customize the Spring Boot entry point class using Command Line Runner, so we will be able to execute our Spring Boot application from command line.<\/p>\n<pre class=\"brush:java\">package com.jcombat.h2demo;\r\n \r\nimport org.slf4j.Logger;\r\nimport org.slf4j.LoggerFactory;\r\nimport org.springframework.beans.factory.annotation.Autowired;\r\nimport org.springframework.boot.CommandLineRunner;\r\nimport org.springframework.boot.SpringApplication;\r\nimport org.springframework.boot.autoconfigure.SpringBootApplication;\r\nimport org.springframework.boot.autoconfigure.domain.EntityScan;\r\nimport org.springframework.data.jpa.repository.config.EnableJpaRepositories;\r\n \r\nimport com.jcombat.repository.StudentRepository;\r\n \r\n@SpringBootApplication\r\n@EntityScan(\"com.jcombat.entity\")\r\n@EnableJpaRepositories(\"com.jcombat.repository\")\r\npublic class H2demoApplication implements CommandLineRunner {\r\n \r\n\t\/\/ mvn spring-boot:run\r\n\tprivate Logger LOG = LoggerFactory.getLogger(\"H2demoApplication\");\r\n\t\r\n\tStudentRepository studentRepository;\r\n\t\r\n\t@Autowired\r\n\tpublic H2demoApplication(StudentRepository studentRepository) {\r\n\t\tthis.studentRepository = studentRepository;\r\n\t}\r\n \r\n\tpublic static void main(String[] args) {\r\n\t\tSpringApplication.run(H2demoApplication.class, args);\r\n\t}\r\n \r\n\t@Override\r\n\tpublic void run(String... args) throws Exception {\r\n\t\tLOG.info(\"Student count in DB: {}\", studentRepository.count());\r\n\t}\r\n}<\/pre>\n<h2>Executing the application<\/h2>\n<p>To run the application, you can either do it directly from your Eclipse IDE, or from command-line through below command \u2013<\/p>\n<pre class=\"brush:bash\">mvn spring-boot:run<\/pre>\n<p>When executed, we see the below output displayed on console \u2013<\/p>\n<p><a href=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/11\/Screenshot_1.png\"><img decoding=\"async\" class=\"aligncenter wp-image-83919\" src=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/11\/Screenshot_1-1024x53.png\" alt=\"\" width=\"820\" height=\"43\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/11\/Screenshot_1-1024x53.png 1024w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/11\/Screenshot_1-300x16.png 300w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/11\/Screenshot_1-768x40.png 768w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/11\/Screenshot_1.png 1173w\" sizes=\"(max-width: 820px) 100vw, 820px\" \/><\/a><\/p>\n<h2>Download the source code<\/h2>\n<p><a href=\"https:\/\/github.com\/abhi435\/H2InMemoryDBSpringBoot\"><img decoding=\"async\" class=\"aligncenter wp-image-83920 size-full\" src=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/11\/button-4.png\" alt=\"H2 InMemory Database\" width=\"316\" height=\"49\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/11\/button-4.png 316w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/11\/button-4-300x47.png 300w\" sizes=\"(max-width: 316px) 100vw, 316px\" \/><\/a><\/p>\n<div class=\"attribution\">\n<table>\n<tbody>\n<tr>\n<td>Published on Java Code Geeks with permission by Abhimanyu Prasad, partner at our <a href=\"\/\/www.javacodegeeks.com\/join-us\/jcg\/\" target=\"_blank\" rel=\"noopener\">JCG program<\/a>. See the original article here: <a href=\"http:\/\/www.jcombat.com\/spring\/understanding-h2-inmemory-database-with-spring-boot\" target=\"_blank\" rel=\"noopener\">Understanding H2 InMemory Database with Spring Boot<\/a><\/p>\n<p>Opinions expressed by Java Code Geeks contributors are their own.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Introduction Basically the database setup involves several steps before we can use it through configured datasource in our application. This actually is required in case of actual project implementations. However, there are situations where we just need a POC to be done for something, and the whole database setup thing still becomes an obligation. Similarly, &hellip;<\/p>\n","protected":false},"author":958,"featured_media":240,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[428,1185,30,854],"class_list":["post-83911","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-enterprise-java","tag-database","tag-h2","tag-spring","tag-spring-boot"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Understanding H2 InMemory Database with Spring Boot - Java Code Geeks<\/title>\n<meta name=\"description\" content=\"Interested to learn about H2 InMemory Database? Check our article explaining how Spring boot integrates an H2 InMemory Database.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.javacodegeeks.com\/2018\/11\/understandin-inmemory-database-spring.html\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Understanding H2 InMemory Database with Spring Boot - Java Code Geeks\" \/>\n<meta property=\"og:description\" content=\"Interested to learn about H2 InMemory Database? Check our article explaining how Spring boot integrates an H2 InMemory Database.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.javacodegeeks.com\/2018\/11\/understandin-inmemory-database-spring.html\" \/>\n<meta property=\"og:site_name\" content=\"Java Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/javacodegeeks\" \/>\n<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/abhi435\" \/>\n<meta property=\"article:published_time\" content=\"2018-11-26T11:00:24+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/spring-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Abhimanyu Prasad\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:site\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Abhimanyu Prasad\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2018\\\/11\\\/understandin-inmemory-database-spring.html#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2018\\\/11\\\/understandin-inmemory-database-spring.html\"},\"author\":{\"name\":\"Abhimanyu Prasad\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/8084cf3db3cc9b2c21fc2c04307d47c7\"},\"headline\":\"Understanding H2 InMemory Database with Spring Boot\",\"datePublished\":\"2018-11-26T11:00:24+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2018\\\/11\\\/understandin-inmemory-database-spring.html\"},\"wordCount\":456,\"commentCount\":1,\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2018\\\/11\\\/understandin-inmemory-database-spring.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/spring-logo.jpg\",\"keywords\":[\"Database\",\"H2\",\"Spring\",\"Spring Boot\"],\"articleSection\":[\"Enterprise Java\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2018\\\/11\\\/understandin-inmemory-database-spring.html#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2018\\\/11\\\/understandin-inmemory-database-spring.html\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2018\\\/11\\\/understandin-inmemory-database-spring.html\",\"name\":\"Understanding H2 InMemory Database with Spring Boot - Java Code Geeks\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2018\\\/11\\\/understandin-inmemory-database-spring.html#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2018\\\/11\\\/understandin-inmemory-database-spring.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/spring-logo.jpg\",\"datePublished\":\"2018-11-26T11:00:24+00:00\",\"description\":\"Interested to learn about H2 InMemory Database? Check our article explaining how Spring boot integrates an H2 InMemory Database.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2018\\\/11\\\/understandin-inmemory-database-spring.html#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2018\\\/11\\\/understandin-inmemory-database-spring.html\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2018\\\/11\\\/understandin-inmemory-database-spring.html#primaryimage\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/spring-logo.jpg\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/spring-logo.jpg\",\"width\":150,\"height\":150,\"caption\":\"spring-interview-questions-answers\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2018\\\/11\\\/understandin-inmemory-database-spring.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Java\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/java\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Enterprise Java\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/java\\\/enterprise-java\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Understanding H2 InMemory Database with Spring Boot\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"name\":\"Java Code Geeks\",\"description\":\"Java Developers Resource Center\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"alternateName\":\"JCG\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.javacodegeeks.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/javacodegeeks\",\"https:\\\/\\\/x.com\\\/javacodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/8084cf3db3cc9b2c21fc2c04307d47c7\",\"name\":\"Abhimanyu Prasad\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/8197b6658b8d42a7c85117f4aabe67206651698dbc306809655610f6af906610?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/8197b6658b8d42a7c85117f4aabe67206651698dbc306809655610f6af906610?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/8197b6658b8d42a7c85117f4aabe67206651698dbc306809655610f6af906610?s=96&d=mm&r=g\",\"caption\":\"Abhimanyu Prasad\"},\"description\":\"Abhimanyu is a passionate tech blogger and senior programmer, who has an extensive end-to-end development experience with wide range of technologies. He is the founder and administrator at jCombat.\",\"sameAs\":[\"http:\\\/\\\/www.jcombat.com\",\"https:\\\/\\\/www.facebook.com\\\/abhi435\"],\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/author\\\/abhimanyu-prasad\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Understanding H2 InMemory Database with Spring Boot - Java Code Geeks","description":"Interested to learn about H2 InMemory Database? Check our article explaining how Spring boot integrates an H2 InMemory Database.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.javacodegeeks.com\/2018\/11\/understandin-inmemory-database-spring.html","og_locale":"en_US","og_type":"article","og_title":"Understanding H2 InMemory Database with Spring Boot - Java Code Geeks","og_description":"Interested to learn about H2 InMemory Database? Check our article explaining how Spring boot integrates an H2 InMemory Database.","og_url":"https:\/\/www.javacodegeeks.com\/2018\/11\/understandin-inmemory-database-spring.html","og_site_name":"Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_author":"https:\/\/www.facebook.com\/abhi435","article_published_time":"2018-11-26T11:00:24+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/spring-logo.jpg","type":"image\/jpeg"}],"author":"Abhimanyu Prasad","twitter_card":"summary_large_image","twitter_creator":"@javacodegeeks","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Abhimanyu Prasad","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.javacodegeeks.com\/2018\/11\/understandin-inmemory-database-spring.html#article","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/2018\/11\/understandin-inmemory-database-spring.html"},"author":{"name":"Abhimanyu Prasad","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/8084cf3db3cc9b2c21fc2c04307d47c7"},"headline":"Understanding H2 InMemory Database with Spring Boot","datePublished":"2018-11-26T11:00:24+00:00","mainEntityOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2018\/11\/understandin-inmemory-database-spring.html"},"wordCount":456,"commentCount":1,"publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2018\/11\/understandin-inmemory-database-spring.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/spring-logo.jpg","keywords":["Database","H2","Spring","Spring Boot"],"articleSection":["Enterprise Java"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.javacodegeeks.com\/2018\/11\/understandin-inmemory-database-spring.html#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.javacodegeeks.com\/2018\/11\/understandin-inmemory-database-spring.html","url":"https:\/\/www.javacodegeeks.com\/2018\/11\/understandin-inmemory-database-spring.html","name":"Understanding H2 InMemory Database with Spring Boot - Java Code Geeks","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2018\/11\/understandin-inmemory-database-spring.html#primaryimage"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2018\/11\/understandin-inmemory-database-spring.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/spring-logo.jpg","datePublished":"2018-11-26T11:00:24+00:00","description":"Interested to learn about H2 InMemory Database? Check our article explaining how Spring boot integrates an H2 InMemory Database.","breadcrumb":{"@id":"https:\/\/www.javacodegeeks.com\/2018\/11\/understandin-inmemory-database-spring.html#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.javacodegeeks.com\/2018\/11\/understandin-inmemory-database-spring.html"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/2018\/11\/understandin-inmemory-database-spring.html#primaryimage","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/spring-logo.jpg","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/spring-logo.jpg","width":150,"height":150,"caption":"spring-interview-questions-answers"},{"@type":"BreadcrumbList","@id":"https:\/\/www.javacodegeeks.com\/2018\/11\/understandin-inmemory-database-spring.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.javacodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"Java","item":"https:\/\/www.javacodegeeks.com\/category\/java"},{"@type":"ListItem","position":3,"name":"Enterprise Java","item":"https:\/\/www.javacodegeeks.com\/category\/java\/enterprise-java"},{"@type":"ListItem","position":4,"name":"Understanding H2 InMemory Database with Spring Boot"}]},{"@type":"WebSite","@id":"https:\/\/www.javacodegeeks.com\/#website","url":"https:\/\/www.javacodegeeks.com\/","name":"Java Code Geeks","description":"Java Developers Resource Center","publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"alternateName":"JCG","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.javacodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.javacodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/www.javacodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/javacodegeeks","https:\/\/x.com\/javacodegeeks"]},{"@type":"Person","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/8084cf3db3cc9b2c21fc2c04307d47c7","name":"Abhimanyu Prasad","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/8197b6658b8d42a7c85117f4aabe67206651698dbc306809655610f6af906610?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/8197b6658b8d42a7c85117f4aabe67206651698dbc306809655610f6af906610?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/8197b6658b8d42a7c85117f4aabe67206651698dbc306809655610f6af906610?s=96&d=mm&r=g","caption":"Abhimanyu Prasad"},"description":"Abhimanyu is a passionate tech blogger and senior programmer, who has an extensive end-to-end development experience with wide range of technologies. He is the founder and administrator at jCombat.","sameAs":["http:\/\/www.jcombat.com","https:\/\/www.facebook.com\/abhi435"],"url":"https:\/\/www.javacodegeeks.com\/author\/abhimanyu-prasad"}]}},"_links":{"self":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/83911","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/users\/958"}],"replies":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=83911"}],"version-history":[{"count":0,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/83911\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media\/240"}],"wp:attachment":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media?parent=83911"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=83911"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=83911"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}