{"id":44216,"date":"2017-03-27T15:00:51","date_gmt":"2017-03-27T12:00:51","guid":{"rendered":"http:\/\/examples.javacodegeeks.com\/?p=44216"},"modified":"2019-03-20T14:01:04","modified_gmt":"2019-03-20T12:01:04","slug":"junit-hsqldb-example","status":"publish","type":"post","link":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-hsqldb-example\/","title":{"rendered":"JUnit HSQLDB Example"},"content":{"rendered":"<p>Here is the new JUnit example, but with a difference. In this example we shall show users how they can use JUnit with HSQLDB for testing. In JUnit HSQLDB example, we will try to explain the usage of HSQLDB. Why we are using HSQLDB and not any other DB?<\/p>\n<p>We will try to explain the answer to this question in this example. Let&#8217;s start by a little introduction of the HSqlDB.<\/p>\n<h2>1. Introduction<\/h2>\n<p><a href=\"http:\/\/hsqldb.org\/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">HSQLDB<\/a> is a 100% Java database. HSQLDB (HyperSQL DataBase) is the leading SQL relational database software written in Java. Latest version 2.3.4 is fully multi-threaded and supports high performance 2PL and MVCC (multi version concurrency control) transaction control models.<\/p>\n<p>We can use this database as a in memory database also. This answers our question that why we are using HSQLDB for our example. We will create in memory database, create a table, insert data into tables and after test cases are executed we will drop table. So all in all we will use database that will work in memory. We will not start any server to run DB nor we stop it.\n<\/p>\n<h2>2. Technologies Used<\/h2>\n<p>We will use the following technologies in this example.<\/p>\n<ul>\n<li><strong>Java<\/strong>: Coding Language<\/li>\n<li><strong>JUnit 4.12<\/strong>: Testing Framework<\/li>\n<li><strong>Maven<\/strong>: Build and Dependency Tool<\/li>\n<li><strong>HSQLDB<\/strong>: In Memory 100% Java database<\/li>\n<li><strong>Eclipse<\/strong>: IDE for coding<\/li>\n<\/ul>\n<h2>3. Project Setup<\/h2>\n<div class=\"tip\"><strong>Tip<\/strong><br \/>\nYou may skip project creation and jump directly to the <a href=\"#code\"><strong>beginning of the example<\/strong><\/a> below.<\/div>\n<p>We will start by creating a Maven project. Open Eclipse. Select <code>File -&gt; New -&gt; Maven Project<\/code>. Fill in the details and click on the <strong>Next<\/strong> button.<\/p>\n<p><figure id=\"attachment_44217\" aria-describedby=\"caption-attachment-44217\" style=\"width: 725px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/03\/junit-hsqldb-example-setup-1.jpg\"><img decoding=\"async\" class=\"size-full wp-image-44217\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/03\/junit-hsqldb-example-setup-1.jpg\" alt=\"JUnit HSqlDB Example Setup 1\" width=\"725\" height=\"503\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/03\/junit-hsqldb-example-setup-1.jpg 725w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/03\/junit-hsqldb-example-setup-1-300x208.jpg 300w\" sizes=\"(max-width: 725px) 100vw, 725px\" \/><\/a><figcaption id=\"caption-attachment-44217\" class=\"wp-caption-text\">Figure 1: JUnit HSqlDB Example Setup 1<\/figcaption><\/figure><\/p>\n<p>On this screen, fill in the details as mentioned below and click on <strong>Finish<\/strong> button.<\/p>\n<p><figure id=\"attachment_44218\" aria-describedby=\"caption-attachment-44218\" style=\"width: 724px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/03\/junit-hsqldb-example-setup-2.jpg\"><img decoding=\"async\" class=\"size-full wp-image-44218\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/03\/junit-hsqldb-example-setup-2.jpg\" alt=\"JUnit HSqlDB Example Setup 2\" width=\"724\" height=\"665\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/03\/junit-hsqldb-example-setup-2.jpg 724w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/03\/junit-hsqldb-example-setup-2-300x276.jpg 300w\" sizes=\"(max-width: 724px) 100vw, 724px\" \/><\/a><figcaption id=\"caption-attachment-44218\" class=\"wp-caption-text\">Figure 2: JUnit HSqlDB Example Setup 2<\/figcaption><\/figure><\/p>\n<p>With this, we are ready with the blank Maven project. Let&#8217;s start filling up the details.<div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<h2>4. JUnit HSQLDB Example<\/h2>\n<p>Starting by writing the below line in the <code>pom.xml<\/code> file. This will fetch all dependencies for our example to work.<\/p>\n<p><span style=\"text-decoration: underline;\"><em>pom.xml<\/em><\/span><\/p>\n<pre class=\"brush:xml;wrap-lines:false;highlight:[3,9,16,17]\">&nbsp;&nbsp;&nbsp; &lt;dependencies&gt;\n&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&lt;dependency&gt;\n&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&lt;groupId&gt;junit&lt;\/groupId&gt;\n&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&lt;artifactId&gt;junit&lt;\/artifactId&gt;\n&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&lt;version&gt;4.12&lt;\/version&gt;\n&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&lt;\/dependency&gt;\n\n&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&lt;dependency&gt;\n&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&lt;groupId&gt;org.hsqldb&lt;\/groupId&gt;\n&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&lt;artifactId&gt;hsqldb&lt;\/artifactId&gt;\n&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&lt;version&gt;2.3.4&lt;\/version&gt;\n&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&lt;\/dependency&gt;\n&nbsp;&nbsp; &nbsp;&lt;\/dependencies&gt;\n\n&nbsp;&nbsp; &nbsp;&lt;properties&gt;\n&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&lt;maven.compiler.source&gt;1.8&lt;\/maven.compiler.source&gt;\n&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&lt;maven.compiler.target&gt;1.8&lt;\/maven.compiler.target&gt;\n&nbsp;&nbsp; &nbsp;&lt;\/properties&gt;\n<\/pre>\n<p>Now this will fetch <code>JUnit jar<\/code>(<strong>line 3<\/strong>), <code>HSLDB jar<\/code>(<strong>line 9<\/strong>) and also tell maven to use Java 1.8 for compiling of this example(<strong>line 16,17<\/strong>).<\/p>\n<h3>4.1 JUnit Test Class<\/h3>\n<p>We will create a test class<\/p>\n<p><span style=\"text-decoration: underline;\"><em>JUnitHSqlDBTest<\/em><\/span><\/p>\n<pre class=\"brush:java;wrap-lines:false;highlight:[19,28,45,64,73,86,91]\">package junithsqldb;\n\nimport static org.hamcrest.CoreMatchers.is;\nimport static org.junit.Assert.assertThat;\n\nimport java.io.IOException;\nimport java.sql.Connection;\nimport java.sql.DriverManager;\nimport java.sql.ResultSet;\nimport java.sql.SQLException;\nimport java.sql.Statement;\n\nimport org.junit.AfterClass;\nimport org.junit.BeforeClass;\nimport org.junit.Test;\n\npublic class JUnitHSqlDBTest {\n\n\t@BeforeClass\n\tpublic static void init() throws SQLException, ClassNotFoundException, IOException {\n\t\tClass.forName(\"org.hsqldb.jdbc.JDBCDriver\");\n\n\t\t\/\/ initialize database\n\t\tinitDatabase();\n\t}\n\t\n\n\t@AfterClass\n\tpublic static void destroy() throws SQLException, ClassNotFoundException, IOException {\n\t\ttry (Connection connection = getConnection(); Statement statement = connection.createStatement();) {\n\t\t\tstatement.executeUpdate(\"DROP TABLE employee\");\n\t\t\tconnection.commit();\n\t\t}\n\t}\n\n\t\/**\n\t * Database initialization for testing i.e.\n\t * &lt;ul&gt;\n\t * &lt;li&gt;Creating Table&lt;\/li&gt;\n\t * &lt;li&gt;Inserting record&lt;\/li&gt;\n\t * &lt;\/ul&gt;\n\t * \n\t * @throws SQLException\n\t *\/\n\tprivate static void initDatabase() throws SQLException {\n\t\ttry (Connection connection = getConnection(); Statement statement = connection.createStatement();) {\n\t\t\tstatement.execute(\"CREATE TABLE employee (id INT NOT NULL, name VARCHAR(50) NOT NULL,\"\n\t\t\t\t\t+ \"email VARCHAR(50) NOT NULL, PRIMARY KEY (id))\");\n\t\t\tconnection.commit();\n\t\t\tstatement.executeUpdate(\n\t\t\t\t\t\"INSERT INTO employee VALUES (1001,'Vinod Kumar Kashyap', 'vinod@javacodegeeks.com')\");\n\t\t\tstatement.executeUpdate(\"INSERT INTO employee VALUES (1002,'Dhwani Kashyap', 'dhwani@javacodegeeks.com')\");\n\t\t\tstatement.executeUpdate(\"INSERT INTO employee VALUES (1003,'Asmi Kashyap', 'asmi@javacodegeeks.com')\");\n\t\t\tconnection.commit();\n\t\t}\n\t}\n\n\t\/**\n\t * Create a connection\n\t * \n\t * @return connection object\n\t * @throws SQLException\n\t *\/\n\tprivate static Connection getConnection() throws SQLException {\n\t\treturn DriverManager.getConnection(\"jdbc:hsqldb:mem:employees\", \"vinod\", \"vinod\");\n\t}\n\n\t\/**\n\t * Get total records in table\n\t * \n\t * @return total number of records. In case of exception 0 is returned\n\t *\/\n\tprivate int getTotalRecords() {\n\t\ttry (Connection connection = getConnection(); Statement statement = connection.createStatement();) {\n\t\t\tResultSet result = statement.executeQuery(\"SELECT count(*) as total FROM employee\");\n\t\t\tif (result.next()) {\n\t\t\t\treturn result.getInt(\"total\");\n\t\t\t}\n\t\t} catch (SQLException e) {\n\t\t\te.printStackTrace();\n\t\t}\n\t\treturn 0;\n\t}\n\n\t@Test\n\tpublic void getTotalRecordsTest() {\n\t\tassertThat(3, is(getTotalRecords()));\n\t}\n\n\t@Test\n\tpublic void checkNameExistsTest() {\n\t\ttry (Connection connection = getConnection();\n\t\t\t\tStatement statement = connection.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,\n\t\t\t\t\t\tResultSet.CONCUR_READ_ONLY);) {\n\n\t\t\tResultSet result = statement.executeQuery(\"SELECT name FROM employee\");\n\n\t\t\tif (result.first()) {\n\t\t\t\tassertThat(\"Vinod Kumar Kashyap\", is(result.getString(\"name\")));\n\t\t\t}\n\n\t\t\tif (result.last()) {\n\t\t\t\tassertThat(\"Asmi Kashyap\", is(result.getString(\"name\")));\n\t\t\t}\n\t\t} catch (SQLException e) {\n\t\t\te.printStackTrace();\n\t\t}\n\t}\n}\n\n<\/pre>\n<p>Now let&#8217;s see each step in this class.<br \/>\n<strong>Line 19<\/strong>: This method will execute before all <code>@Test<\/code> cases. It will initialize our DB that will be used to test.<br \/>\n<strong>Line 28<\/strong>: This method will execute after all <code>@Test<\/code> cases are executed. We will drop table in this method<br \/>\n<strong>Line 45<\/strong>: Initialize DB with table creation and insertion of records.<br \/>\n<strong>Line 64<\/strong>: Creating a connection.<br \/>\n<strong>Line 73<\/strong>: Return total number of records in DB.<br \/>\n<strong>Line 86<\/strong>: <code>@Test<\/code> method to test case for total number of records.<br \/>\n<strong>Line 91<\/strong>: <code>@Test<\/code> method to test for fetch records.[ulp id=&#8217;ODQaBEw1BIbHApZq&#8217;]<\/p>\n<p><span style=\"text-decoration: underline;\"><em>Output<\/em><\/span><\/p>\n<p><figure id=\"attachment_44219\" aria-describedby=\"caption-attachment-44219\" style=\"width: 704px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/03\/junit-hsqldb-example-output.jpg\"><img decoding=\"async\" class=\"size-full wp-image-44219\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/03\/junit-hsqldb-example-output.jpg\" alt=\"JUnit HSqlDB Example Output\" width=\"704\" height=\"246\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/03\/junit-hsqldb-example-output.jpg 704w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/03\/junit-hsqldb-example-output-300x105.jpg 300w\" sizes=\"(max-width: 704px) 100vw, 704px\" \/><\/a><figcaption id=\"caption-attachment-44219\" class=\"wp-caption-text\">Figure 3: JUnit HSqlDB Example Output<\/figcaption><\/figure><\/p>\n<h2>5. Conclusion<\/h2>\n<p>In this example, users have learnt that how we can test out methods by using in memory database HSQLDB. We have used this 100% Java database HSQLDB.<\/p>\n<h2>6. Download the Eclipse Project<\/h2>\n<p>This is a JUnit HSQLDB example.<\/p>\n<div class=\"download\"><strong>Download<\/strong><br \/>\nYou can download the full source code of this example here: <a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/03\/junithsqldb.zip\"><strong>JunitHSqlDB.zip<\/strong><\/a><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Here is the new JUnit example, but with a difference. In this example we shall show users how they can use JUnit with HSQLDB for testing. In JUnit HSQLDB example, we will try to explain the usage of HSQLDB. Why we are using HSQLDB and not any other DB? We will try to explain the &hellip;<\/p>\n","protected":false},"author":112,"featured_media":6678,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[25],"tags":[1653],"class_list":["post-44216","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-junit","tag-hsqldb"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>JUnit HSQLDB Example - Java Code Geeks<\/title>\n<meta name=\"description\" content=\"Here is the new JUnit example, but with a difference. In JUnit HSQLDB example, we will try to explain the usage of HSQLDB. In this example we shall show\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-hsqldb-example\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"JUnit HSQLDB Example - Java Code Geeks\" \/>\n<meta property=\"og:description\" content=\"Here is the new JUnit example, but with a difference. In JUnit HSQLDB example, we will try to explain the usage of HSQLDB. In this example we shall show\" \/>\n<meta property=\"og:url\" content=\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-hsqldb-example\/\" \/>\n<meta property=\"og:site_name\" content=\"Examples Java Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/javacodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2017-03-27T12:00:51+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2019-03-20T12:01:04+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/11\/junit-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=\"Vinod Kumar Kashyap\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@vinodkashyap\" \/>\n<meta name=\"twitter:site\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Vinod Kumar Kashyap\" \/>\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:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-hsqldb-example\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-hsqldb-example\/\"},\"author\":{\"name\":\"Vinod Kumar Kashyap\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/1d6281e8235e49b5b8614621c2445d2c\"},\"headline\":\"JUnit HSQLDB Example\",\"datePublished\":\"2017-03-27T12:00:51+00:00\",\"dateModified\":\"2019-03-20T12:01:04+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-hsqldb-example\/\"},\"wordCount\":517,\"commentCount\":1,\"publisher\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-hsqldb-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/11\/junit-logo.jpg\",\"keywords\":[\"hsqldb\"],\"articleSection\":[\"junit\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-hsqldb-example\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-hsqldb-example\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-hsqldb-example\/\",\"name\":\"JUnit HSQLDB Example - Java Code Geeks\",\"isPartOf\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-hsqldb-example\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-hsqldb-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/11\/junit-logo.jpg\",\"datePublished\":\"2017-03-27T12:00:51+00:00\",\"dateModified\":\"2019-03-20T12:01:04+00:00\",\"description\":\"Here is the new JUnit example, but with a difference. In JUnit HSQLDB example, we will try to explain the usage of HSQLDB. In this example we shall show\",\"breadcrumb\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-hsqldb-example\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-hsqldb-example\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-hsqldb-example\/#primaryimage\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/11\/junit-logo.jpg\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/11\/junit-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-hsqldb-example\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/examples.javacodegeeks.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Java Development\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/java-development\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Core Java\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/java-development\/core-java\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"junit\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/java-development\/core-java\/junit\/\"},{\"@type\":\"ListItem\",\"position\":5,\"name\":\"JUnit HSQLDB Example\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#website\",\"url\":\"https:\/\/examples.javacodegeeks.com\/\",\"name\":\"Java Code Geeks\",\"description\":\"Java Examples and Code Snippets\",\"publisher\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\"},\"alternateName\":\"JCG\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/examples.javacodegeeks.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\/\/examples.javacodegeeks.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/javacodegeeks\",\"https:\/\/x.com\/javacodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/1d6281e8235e49b5b8614621c2445d2c\",\"name\":\"Vinod Kumar Kashyap\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/a11634ec460c849e8631b740af1b75cb68c9c58d5c2339c21bcd95f55b9af4f5?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/a11634ec460c849e8631b740af1b75cb68c9c58d5c2339c21bcd95f55b9af4f5?s=96&d=mm&r=g\",\"caption\":\"Vinod Kumar Kashyap\"},\"description\":\"Vinod is Sun Certified and love to work in Java and related technologies. Having more than 13 years of experience, he had developed software's including technologies like Java, Hibernate, Struts, Spring, HTML 5, jQuery, CSS, Web Services, MongoDB, AngularJS, AWS. He is also a JUG Leader of Chandigarh Java User Group.\",\"sameAs\":[\"http:\/\/www.vinodkashyap.com\/\",\"https:\/\/www.instagram.com\/vinodkashyap\/\",\"https:\/\/in.linkedin.com\/in\/vinodkashyap\",\"https:\/\/in.pinterest.com\/vinodkashyap\/\",\"https:\/\/x.com\/vinodkashyap\"],\"url\":\"https:\/\/examples.javacodegeeks.com\/author\/vinod-kashyap\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"JUnit HSQLDB Example - Java Code Geeks","description":"Here is the new JUnit example, but with a difference. In JUnit HSQLDB example, we will try to explain the usage of HSQLDB. In this example we shall show","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:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-hsqldb-example\/","og_locale":"en_US","og_type":"article","og_title":"JUnit HSQLDB Example - Java Code Geeks","og_description":"Here is the new JUnit example, but with a difference. In JUnit HSQLDB example, we will try to explain the usage of HSQLDB. In this example we shall show","og_url":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-hsqldb-example\/","og_site_name":"Examples Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2017-03-27T12:00:51+00:00","article_modified_time":"2019-03-20T12:01:04+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/11\/junit-logo.jpg","type":"image\/jpeg"}],"author":"Vinod Kumar Kashyap","twitter_card":"summary_large_image","twitter_creator":"@vinodkashyap","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Vinod Kumar Kashyap","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-hsqldb-example\/#article","isPartOf":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-hsqldb-example\/"},"author":{"name":"Vinod Kumar Kashyap","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/1d6281e8235e49b5b8614621c2445d2c"},"headline":"JUnit HSQLDB Example","datePublished":"2017-03-27T12:00:51+00:00","dateModified":"2019-03-20T12:01:04+00:00","mainEntityOfPage":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-hsqldb-example\/"},"wordCount":517,"commentCount":1,"publisher":{"@id":"https:\/\/examples.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-hsqldb-example\/#primaryimage"},"thumbnailUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/11\/junit-logo.jpg","keywords":["hsqldb"],"articleSection":["junit"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-hsqldb-example\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-hsqldb-example\/","url":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-hsqldb-example\/","name":"JUnit HSQLDB Example - Java Code Geeks","isPartOf":{"@id":"https:\/\/examples.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-hsqldb-example\/#primaryimage"},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-hsqldb-example\/#primaryimage"},"thumbnailUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/11\/junit-logo.jpg","datePublished":"2017-03-27T12:00:51+00:00","dateModified":"2019-03-20T12:01:04+00:00","description":"Here is the new JUnit example, but with a difference. In JUnit HSQLDB example, we will try to explain the usage of HSQLDB. In this example we shall show","breadcrumb":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-hsqldb-example\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-hsqldb-example\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-hsqldb-example\/#primaryimage","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/11\/junit-logo.jpg","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/11\/junit-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-hsqldb-example\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/examples.javacodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"Java Development","item":"https:\/\/examples.javacodegeeks.com\/category\/java-development\/"},{"@type":"ListItem","position":3,"name":"Core Java","item":"https:\/\/examples.javacodegeeks.com\/category\/java-development\/core-java\/"},{"@type":"ListItem","position":4,"name":"junit","item":"https:\/\/examples.javacodegeeks.com\/category\/java-development\/core-java\/junit\/"},{"@type":"ListItem","position":5,"name":"JUnit HSQLDB Example"}]},{"@type":"WebSite","@id":"https:\/\/examples.javacodegeeks.com\/#website","url":"https:\/\/examples.javacodegeeks.com\/","name":"Java Code Geeks","description":"Java Examples and Code Snippets","publisher":{"@id":"https:\/\/examples.javacodegeeks.com\/#organization"},"alternateName":"JCG","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/examples.javacodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/examples.javacodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/examples.javacodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/javacodegeeks","https:\/\/x.com\/javacodegeeks"]},{"@type":"Person","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/1d6281e8235e49b5b8614621c2445d2c","name":"Vinod Kumar Kashyap","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/a11634ec460c849e8631b740af1b75cb68c9c58d5c2339c21bcd95f55b9af4f5?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/a11634ec460c849e8631b740af1b75cb68c9c58d5c2339c21bcd95f55b9af4f5?s=96&d=mm&r=g","caption":"Vinod Kumar Kashyap"},"description":"Vinod is Sun Certified and love to work in Java and related technologies. Having more than 13 years of experience, he had developed software's including technologies like Java, Hibernate, Struts, Spring, HTML 5, jQuery, CSS, Web Services, MongoDB, AngularJS, AWS. He is also a JUG Leader of Chandigarh Java User Group.","sameAs":["http:\/\/www.vinodkashyap.com\/","https:\/\/www.instagram.com\/vinodkashyap\/","https:\/\/in.linkedin.com\/in\/vinodkashyap","https:\/\/in.pinterest.com\/vinodkashyap\/","https:\/\/x.com\/vinodkashyap"],"url":"https:\/\/examples.javacodegeeks.com\/author\/vinod-kashyap\/"}]}},"_links":{"self":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/44216","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/users\/112"}],"replies":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=44216"}],"version-history":[{"count":0,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/44216\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/media\/6678"}],"wp:attachment":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/media?parent=44216"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=44216"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=44216"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}