{"id":48845,"date":"2017-08-02T11:00:08","date_gmt":"2017-08-02T08:00:08","guid":{"rendered":"http:\/\/examples.javacodegeeks.com\/?p=48845"},"modified":"2019-03-05T13:05:28","modified_gmt":"2019-03-05T11:05:28","slug":"jdbc-resultsetextractor-example","status":"publish","type":"post","link":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/sql\/jdbc-resultsetextractor-example\/","title":{"rendered":"JDBC ResultSetExtractor Example"},"content":{"rendered":"<p><strong>Spring<\/strong> provides a simplification in handling database access with the Spring JDBC Template. The <code>org.springframework.jdbc.core.ResultSetExtractor<\/code> interface is a callback interface used by JdbcTemplate&#8217;s query methods. Implementations of this interface perform the actual work of extracting results from an&nbsp;<strong>SQL<\/strong> <code>ResultSet<\/code> object.<\/p>\n<p>In this article, we will try to show how the <code>ResultSetExtractor<\/code> mechanism can be applied to a Java application.<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n&nbsp;\n<\/p>\n<h2>1. Introduction<\/h2>\n<p>In Spring JDBC development, developers can use <code>JdbcTemplate<\/code> and <code>JdbcDaoSupport<\/code> classes to simplify the overall database operation processes. Spring JdbcTemplate is a powerful mechanism to connect to the database and execute SQL queries. It internally uses JDBC API but eliminates a lot of problems of JDBC API.<\/p>\n<p>The Spring JDBC Template has the following advantages compared with the standard JDBC API,<\/p>\n<ul>\n<li>The Spring JDBC template allows to clean-up the resources automatically, e.g. release the database connections.<\/li>\n<li>The Spring JDBC template converts the standard JDBC SQL Exceptions into <code>RuntimeExceptions<\/code>. This allows the programmer to react more flexible to the errors.<\/li>\n<li>The Spring JDBC template also converts the vendor specific error messages into better understandable error messages.<\/li>\n<\/ul>\n<h3>1.1 Problems of JDBC API<\/h3>\n<p>The problems of JDBC API are as follows:<\/p>\n<ul>\n<li>We need to write a lot of code before and after executing the query, such as creating <code>Connection<\/code>, <code>Statement<\/code>, Closing <code>ResultSet<\/code>, <code>Statement<\/code>, and <code>Connection<\/code>.<\/li>\n<li>We need to perform exception handling on the database logic.<\/li>\n<li>We need to handle transactions.<\/li>\n<li>Repetition of all these codes from one database logic to another is a time-consuming task.<\/li>\n<\/ul>\n<p>Spring <code>JdbcTemplate<\/code> eliminates all the above-mentioned problems of JDBC API and provides methods to write the queries directly. Let\u2019s take a look and understand the <code>ResultSetExtractor<\/code> interface.<\/p>\n<h3>1.2 ResultSetExtractor Interface<\/h3>\n<p>The <code>org.springframework.jdbc.core.ResultSetExtractor<\/code> interface can be used to fetch records from the database. It accepts a <code>ResultSet<\/code> as a method argument and returns the <code>List<\/code>. Implementation of this interface perform the actual work of extracting results from a <code>ResultSet<\/code>, but you don&#8217;t need to worry about exception handling.<\/p>\n<p>SQL Exceptions will be caught and handled by the calling <code>JdbcTemplate<\/code>. This interface is mainly used within the JDBC framework itself. The <code>org.springframework.jdbc.core.ResultSetExtractor<\/code> interface defines only one method <code>extractData<\/code> that accepts <code>ResultSet<\/code> instance as a parameter. The syntax of the method is given below:<\/p>\n<p><span style=\"text-decoration: underline;\"><em>Method Signature<\/em><\/span><\/p>\n<pre class=\"brush:java; wrap-lines:false;\">public List extractData(ResultSet rs) throws SQLException, DataAccessException {\n\t\/\/ Database Logic\n}\n<\/pre>\n<h3>1.3 Download and Install MySQL<\/h3>\n<p>You can watch <a href=\"https:\/\/www.youtube.com\/watch?v=z1t9m7K6cpI\" target=\"_blank\" rel=\"noopener noreferrer\">this<\/a> video in order to download and install the MySQL database on your windows operations system.<\/p>\n<p>Now, open up the Eclipse IDE and let\u2019s start building the application!<\/p>\n<h2>2. JDBC ResultSetExtractor Example<\/h2>\n<h3>2.1 Tools Used<\/h3>\n<p>We are using Eclipse Kepler SR2, JDK 8, MySQL database and Maven (to download the MySQL connector and Spring libraries). Having said that, we have tested the code against JDK 1.7 and it works well.<\/p>\n<h3>2.2 Project Structure<\/h3>\n<p>Firstly, let\u2019s review the final project structure, in case you are confused about where you should create the corresponding files or folder later!<\/p>\n<p><figure id=\"attachment_48846\" aria-describedby=\"caption-attachment-48846\" style=\"width: 305px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-resultset-extractor-project-structure.jpg\"><img decoding=\"async\" class=\"wp-image-48846 size-full\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-resultset-extractor-project-structure.jpg\" alt=\"Fig. 1: JDBC ResultSetExtractor Application Project Structure\" width=\"305\" height=\"309\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-resultset-extractor-project-structure.jpg 305w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-resultset-extractor-project-structure-296x300.jpg 296w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-resultset-extractor-project-structure-70x70.jpg 70w\" sizes=\"(max-width: 305px) 100vw, 305px\" \/><\/a><figcaption id=\"caption-attachment-48846\" class=\"wp-caption-text\">Fig. 1: JDBC ResultSetExtractor Application Project Structure<\/figcaption><\/figure><\/p>\n<h3>2.3 Project Creation<\/h3>\n<p>This section will demonstrate on how to create a Dynamic Web Java Maven project with Eclipse. In Eclipse IDE, go to <code>File -&gt; New -&gt; Maven Project<\/code><\/p>\n<p><figure id=\"attachment_48848\" aria-describedby=\"caption-attachment-48848\" style=\"width: 652px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-resultset-extractor-example-project-guide-1.jpg\"><img decoding=\"async\" class=\"size-full wp-image-48848\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-resultset-extractor-example-project-guide-1.jpg\" alt=\"Fig. 2: Create Maven Project\" width=\"652\" height=\"712\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-resultset-extractor-example-project-guide-1.jpg 652w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-resultset-extractor-example-project-guide-1-275x300.jpg 275w\" sizes=\"(max-width: 652px) 100vw, 652px\" \/><\/a><figcaption id=\"caption-attachment-48848\" class=\"wp-caption-text\">Fig. 2: Create Maven Project<\/figcaption><\/figure><\/p>\n<p>In the New Maven Project window, it will ask you to select project location. By default, &#8216;<em>Use default workspace location<\/em>&#8216; will be selected. Select the &#8216;<em>Create a simple project (skip archetype selection)<\/em>&#8216; checkbox and just click on next button to proceed.<\/p>\n<p><figure id=\"attachment_48849\" aria-describedby=\"caption-attachment-48849\" style=\"width: 804px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-resultset-extractor-example-project-guide-2.jpg\"><img decoding=\"async\" class=\"size-full wp-image-48849\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-resultset-extractor-example-project-guide-2.jpg\" alt=\"Fig. 3: Project Details\" width=\"804\" height=\"541\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-resultset-extractor-example-project-guide-2.jpg 804w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-resultset-extractor-example-project-guide-2-300x202.jpg 300w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-resultset-extractor-example-project-guide-2-768x517.jpg 768w\" sizes=\"(max-width: 804px) 100vw, 804px\" \/><\/a><figcaption id=\"caption-attachment-48849\" class=\"wp-caption-text\">Fig. 3: Project Details<\/figcaption><\/figure><\/p>\n<p>It will ask you to &#8216;Enter a group id for the artifact.&#8217; We will input the details as shown in the below image. The version number will be by default <code>0.0.1-SNAPSHOT<\/code>.<\/p>\n<p><figure id=\"attachment_48850\" aria-describedby=\"caption-attachment-48850\" style=\"width: 602px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-resultset-extractor-example-project-guide-3.jpg\"><img decoding=\"async\" class=\"size-full wp-image-48850\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-resultset-extractor-example-project-guide-3.jpg\" alt=\"Fig. 4: Archetype Parameters\" width=\"602\" height=\"544\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-resultset-extractor-example-project-guide-3.jpg 602w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-resultset-extractor-example-project-guide-3-300x271.jpg 300w\" sizes=\"(max-width: 602px) 100vw, 602px\" \/><\/a><figcaption id=\"caption-attachment-48850\" class=\"wp-caption-text\">Fig. 4: Archetype Parameters<\/figcaption><\/figure><\/p>\n<p>Click on Finish and now the creation of a maven project is completed. If you observe, it has downloaded the maven dependencies and a <code>pom.xml<\/code> file will be created. It will have the following code:<\/p>\n<p><span style=\"text-decoration: underline;\"><em>pom.xml<\/em><\/span><\/p>\n<pre class=\"brush:xml; wrap-lines:false;\">&lt;project xmlns=\"http:\/\/maven.apache.org\/POM\/4.0.0\" xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\" xsi:schemaLocation=\"http:\/\/maven.apache.org\/POM\/4.0.0 http:\/\/maven.apache.org\/xsd\/maven-4.0.0.xsd\"&gt;\n\t&lt;modelVersion&gt;4.0.0&lt;\/modelVersion&gt;\n\t&lt;groupId&gt;JdbcResultSetExtractor&lt;\/groupId&gt;\n\t&lt;artifactId&gt;JdbcResultSetExtractor&lt;\/artifactId&gt;\n\t&lt;version&gt;0.0.1-SNAPSHOT&lt;\/version&gt;\n&lt;\/project&gt;\n<\/pre>\n<p>We can start adding the dependencies that developers want like MySQL, Spring Jars etc. Let\u2019s start building the application!<div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<h2>3. Application Building<\/h2>\n<p>Below are the steps involved in developing this application:<\/p>\n<h3>3.1 Database &amp; Table Creation<\/h3>\n<p>This tutorial uses a database called <code>tutorialDb<\/code>. The database is not included when you create the project in eclipse so you first need to create the database to follow this tutorial:<\/p>\n<ul>\n<li>Create a new database <code>tutorialDb<\/code> as:<\/li>\n<\/ul>\n<pre class=\"brush:sql;\">CREATE DATABASE tutorialDb;\n<\/pre>\n<ul>\n<li>Use the created database <code>tutorialDb<\/code> to create table as:<\/li>\n<\/ul>\n<pre class=\"brush:sql;\">USE tutorialDb;\n<\/pre>\n<ul>\n<li>Create the table <code>tech_editors<\/code> as shown below:<\/li>\n<\/ul>\n<pre class=\"brush:sql; wrap-lines:false;\">CREATE TABLE tech_editors (id int(11) NOT NULL AUTO_INCREMENT, name varchar(100) DEFAULT NULL, salary int(11) NOT NULL, PRIMARY KEY (id));\n<\/pre>\n<ul>\n<li>Now we shall insert some values into the <code>tech_editors<\/code> table as:<\/li>\n<\/ul>\n<pre class=\"&quot;brush:sql;\">INSERT INTO tech_editors (id, name, salary) VALUES (1, 'Java Code Geek', 10000);\n\nINSERT INTO tech_editors (id, name, salary) VALUES (2, 'Harry Potter', 5000);\n\nINSERT INTO tech_editors (id, name, salary) VALUES (3, 'Lucifer', 5500);\n<\/pre>\n<p>If everything goes well, the table will be shown as below in the MySQL workbench:<\/p>\n<p><figure id=\"attachment_48851\" aria-describedby=\"caption-attachment-48851\" style=\"width: 849px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-result-set-extractor-database-output.jpg\"><img decoding=\"async\" class=\"size-full wp-image-48851\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-result-set-extractor-database-output.jpg\" alt=\"Fig. 5: Database and Table Creation\" width=\"849\" height=\"436\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-result-set-extractor-database-output.jpg 849w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-result-set-extractor-database-output-300x154.jpg 300w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-result-set-extractor-database-output-768x394.jpg 768w\" sizes=\"(max-width: 849px) 100vw, 849px\" \/><\/a><figcaption id=\"caption-attachment-48851\" class=\"wp-caption-text\">Fig. 5: Database and Table Creation<\/figcaption><\/figure><\/p>\n<h3>3.2 Maven Dependencies<\/h3>\n<p>In this example, we are using latest MySQL version i.e. <code>mysql-connector-java-5.1.41<\/code> and Spring dependencies. The <strong>updated<\/strong> file will have the following code:<\/p>\n<p><span style=\"text-decoration: underline;\"><em>pom.xml<\/em><\/span><\/p>\n<pre class=\"brush:xml; wrap-lines:false;\">&lt;project xmlns=\"http:\/\/maven.apache.org\/POM\/4.0.0\" xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\" xsi:schemaLocation=\"http:\/\/maven.apache.org\/POM\/4.0.0 http:\/\/maven.apache.org\/xsd\/maven-4.0.0.xsd\"&gt;\n\t&lt;modelVersion&gt;4.0.0&lt;\/modelVersion&gt;\n\t&lt;groupId&gt;JdbcResultSetExtractor&lt;\/groupId&gt;\n\t&lt;artifactId&gt;JdbcResultSetExtractor&lt;\/artifactId&gt;\n\t&lt;version&gt;0.0.1-SNAPSHOT&lt;\/version&gt;\n\t&lt;packaging&gt;jar&lt;\/packaging&gt;\n\t&lt;dependencies&gt;\n\t\t&lt;dependency&gt;\n\t\t\t&lt;groupId&gt;mysql&lt;\/groupId&gt;\n\t\t\t&lt;artifactId&gt;mysql-connector-java&lt;\/artifactId&gt;\n\t\t\t&lt;version&gt;5.1.41&lt;\/version&gt;\n\t\t&lt;\/dependency&gt;\n\t\t&lt;dependency&gt;\n\t\t\t&lt;groupId&gt;org.springframework&lt;\/groupId&gt;\n\t\t\t&lt;artifactId&gt;spring-jdbc&lt;\/artifactId&gt;\n\t\t\t&lt;version&gt;4.3.10.RELEASE&lt;\/version&gt;\n\t\t&lt;\/dependency&gt;\n\t\t&lt;dependency&gt;\n\t\t\t&lt;groupId&gt;org.springframework&lt;\/groupId&gt;\n\t\t\t&lt;artifactId&gt;spring-context&lt;\/artifactId&gt;\n\t\t\t&lt;version&gt;4.3.9.RELEASE&lt;\/version&gt;\n\t\t&lt;\/dependency&gt;\n\t&lt;\/dependencies&gt;\n\t&lt;build&gt;\n\t\t&lt;finalName&gt;${project.artifactId}&lt;\/finalName&gt;\n\t&lt;\/build&gt;\n&lt;\/project&gt;\n<\/pre>\n<h3>3.3 Java Class Creation<\/h3>\n<p>Let\u2019s create the required java files. Right click on <code>src\/main\/java<\/code> folder, <code>New -&gt; Package<\/code>.<\/p>\n<p><figure id=\"attachment_48852\" aria-describedby=\"caption-attachment-48852\" style=\"width: 684px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-resultset-extractor-example-project-guide-4.jpg\"><img decoding=\"async\" class=\"size-full wp-image-48852\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-resultset-extractor-example-project-guide-4.jpg\" alt=\"Fig. 6: Java Package Creation\" width=\"684\" height=\"657\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-resultset-extractor-example-project-guide-4.jpg 684w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-resultset-extractor-example-project-guide-4-300x288.jpg 300w\" sizes=\"(max-width: 684px) 100vw, 684px\" \/><\/a><figcaption id=\"caption-attachment-48852\" class=\"wp-caption-text\">Fig. 6: Java Package Creation<\/figcaption><\/figure><\/p>\n<p>A new pop window will open where we will enter the package name as <code>com.jdbc.resultset.extractor<\/code>.<\/p>\n<p><figure id=\"attachment_48853\" aria-describedby=\"caption-attachment-48853\" style=\"width: 521px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-resultset-extractor-example-project-guide-5.jpg\"><img decoding=\"async\" class=\"size-full wp-image-48853\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-resultset-extractor-example-project-guide-5.jpg\" alt=\"Fig. 7: Java Package Name (com.jdbc.resultset.extractor)\" width=\"521\" height=\"429\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-resultset-extractor-example-project-guide-5.jpg 521w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-resultset-extractor-example-project-guide-5-300x247.jpg 300w\" sizes=\"(max-width: 521px) 100vw, 521px\" \/><\/a><figcaption id=\"caption-attachment-48853\" class=\"wp-caption-text\">Fig. 7: Java Package Name (com.jdbc.resultset.extractor)<\/figcaption><\/figure><\/p>\n<p>Once the package is created in the application, we will need to create the implementation class. Right click on the newly created package, <code>New -&gt; Class<\/code>.<\/p>\n<p><figure id=\"attachment_48854\" aria-describedby=\"caption-attachment-48854\" style=\"width: 742px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-resultset-extractor-example-project-guide-6.jpg\"><img decoding=\"async\" class=\"size-full wp-image-48854\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-resultset-extractor-example-project-guide-6.jpg\" alt=\"Fig. 8: Java Class Creation\" width=\"742\" height=\"655\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-resultset-extractor-example-project-guide-6.jpg 742w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-resultset-extractor-example-project-guide-6-300x265.jpg 300w\" sizes=\"(max-width: 742px) 100vw, 742px\" \/><\/a><figcaption id=\"caption-attachment-48854\" class=\"wp-caption-text\">Fig. 8: Java Class Creation<\/figcaption><\/figure><\/p>\n<p>A new pop window will open and enter the file name as <code>TechEditor<\/code>. The POJO class will be created inside the package: <code>com.jdbc.resultset.extractor<\/code>.<\/p>\n<p><figure id=\"attachment_48855\" aria-describedby=\"caption-attachment-48855\" style=\"width: 535px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-resultset-extractor-example-project-guide-7.jpg\"><img decoding=\"async\" class=\"size-full wp-image-48855\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-resultset-extractor-example-project-guide-7.jpg\" alt=\"Fig. 9: Java Class (TechEditor.java)\" width=\"535\" height=\"632\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-resultset-extractor-example-project-guide-7.jpg 535w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-resultset-extractor-example-project-guide-7-254x300.jpg 254w\" sizes=\"(max-width: 535px) 100vw, 535px\" \/><\/a><figcaption id=\"caption-attachment-48855\" class=\"wp-caption-text\">Fig. 9: Java Class (TechEditor.java)<\/figcaption><\/figure><\/p>\n<p>Repeat the step (i.e. Fig. 8) and enter the filename as <code>TechEditorDao<\/code>. The DAO class with the JDBC Template will be created inside the package: <code>com.jdbc.resultset.extractor<\/code>.<\/p>\n<p><figure id=\"attachment_48856\" aria-describedby=\"caption-attachment-48856\" style=\"width: 534px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-resultset-extractor-example-project-guide-8.jpg\"><img decoding=\"async\" class=\"size-full wp-image-48856\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-resultset-extractor-example-project-guide-8.jpg\" alt=\"Fig. 10: Java Class (TechEditorDao.java)\" width=\"534\" height=\"631\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-resultset-extractor-example-project-guide-8.jpg 534w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-resultset-extractor-example-project-guide-8-254x300.jpg 254w\" sizes=\"(max-width: 534px) 100vw, 534px\" \/><\/a><figcaption id=\"caption-attachment-48856\" class=\"wp-caption-text\">Fig. 10: Java Class (TechEditorDao.java)<\/figcaption><\/figure><\/p>\n<p>Again, repeat the step listed in Fig. 8 and enter the file name as <code>JdbcResultSet<\/code>. The implementation class for testing the Spring JDBC Template will be created inside the package: <code>com.jdbc.resultset.extractor<\/code>.<\/p>\n<p><figure id=\"attachment_48857\" aria-describedby=\"caption-attachment-48857\" style=\"width: 536px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-resultset-extractor-example-project-guide-9.jpg\"><img decoding=\"async\" class=\"size-full wp-image-48857\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-resultset-extractor-example-project-guide-9.jpg\" alt=\"Fig. 11: Java Class (JdbcResultSet.java)\" width=\"536\" height=\"631\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-resultset-extractor-example-project-guide-9.jpg 536w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-resultset-extractor-example-project-guide-9-255x300.jpg 255w\" sizes=\"(max-width: 536px) 100vw, 536px\" \/><\/a><figcaption id=\"caption-attachment-48857\" class=\"wp-caption-text\">Fig. 11: Java Class (JdbcResultSet.java)<\/figcaption><\/figure>[ulp id=&#8217;TD36VgQCKfhTAygK&#8217;]<\/p>\n<h4>3.3.1 Implementation of POJO Class<\/h4>\n<p>This class contains 3 properties with setter and getters method and also defines an extra method <code>toString()<\/code>. Add the following code to it:<\/p>\n<p><span style=\"text-decoration: underline;\"><em>TechEditor.java<\/em><\/span><\/p>\n<pre class=\"brush:java; wrap-lines:false;\">package com.jdbc.resultset.extractor;\n\npublic class TechEditor {\n\n\tprivate int editor_id;\n\tprivate String editor_name;\n\tprivate float editor_salary;\n\n\tpublic int getEditor_id() {\n\t\treturn editor_id;\n\t}\n\n\tpublic void setEditor_id(int editor_id) {\n\t\tthis.editor_id = editor_id;\n\t}\n\n\tpublic String getEditor_name() {\n\t\treturn editor_name;\n\t}\n\n\tpublic void setEditor_name(String editor_name) {\n\t\tthis.editor_name = editor_name;\n\t}\n\tpublic float getEditor_salary() {\n\t\treturn editor_salary;\n\t}\n\n\tpublic void setEditor_salary(float editor_salary) {\n\t\tthis.editor_salary = editor_salary;\n\t}\n\n\tpublic String toString() {\n\t\treturn \"Editor Id= \" + editor_id + \", Name= \" + editor_name + \", Salary= \" + editor_salary +\" $\";\n\t}\n}\n<\/pre>\n<h4>3.3.2 Implementation of DAO Class<\/h4>\n<p>This class contains the <code>JdbcTemplate<\/code> property and a method to fetch the records from the database. Add the following code to it:<\/p>\n<p><span style=\"text-decoration: underline;\"><em>TechEditorDao.java<\/em><\/span><\/p>\n<pre class=\"brush:java; wrap-lines:false;\">package com.jdbc.resultset.extractor;\n\nimport java.sql.ResultSet;\nimport java.sql.SQLException;\nimport java.util.ArrayList;\nimport java.util.List;\n\nimport org.springframework.dao.DataAccessException;\nimport org.springframework.jdbc.core.JdbcTemplate;\nimport org.springframework.jdbc.core.ResultSetExtractor;\n\npublic class TechEditorDao {\n\n\tprivate JdbcTemplate templateObj;\n\n\tpublic void setTemplateObj(JdbcTemplate template) {\n\t\tthis.templateObj = template;\n\t}\n\n\t\/\/ Implementing Custom ResultSetExtractor To Fetch Data From The Db\n\tpublic List getAllEditors() {\n\t\treturn templateObj.query(\"SELECT * FROM tech_editors\", new ResultSetExtractor&lt;List&gt;() {\n\t\t\tpublic List extractData(ResultSet resultSetObj) throws SQLException, DataAccessException {\n\t\t\t\tList editorList = new ArrayList();\n\t\t\t\twhile(resultSetObj.next()) {\n\t\t\t\t\tTechEditor techEditorObj = new TechEditor();\n\t\t\t\t\ttechEditorObj.setEditor_id(resultSetObj.getInt(1));\n\t\t\t\t\ttechEditorObj.setEditor_name(resultSetObj.getString(\"name\"));\n\t\t\t\t\ttechEditorObj.setEditor_salary(resultSetObj.getFloat(3));\n\t\t\t\t\teditorList.add(techEditorObj);\n\t\t\t\t}\n\t\t\t\treturn editorList;\n\t\t\t}\n\t\t});\n\t}\n}\n<\/pre>\n<h4>3.3.3 Implementation of Main Class<\/h4>\n<p>This class gets the DAO bean from the <code>applicationContext.xml<\/code> file and calls the DAO class method. Add the following code to it:<\/p>\n<p><span style=\"text-decoration: underline;\"><em>JdbcResultSet.java<\/em><\/span><\/p>\n<pre class=\"brush:java; wrap-lines:false;\">package com.jdbc.resultset.extractor;\n\nimport java.util.List;\n\nimport org.springframework.context.ApplicationContext;\nimport org.springframework.context.support.ClassPathXmlApplicationContext;\n\npublic class JdbcResultSet {\n\n\t@SuppressWarnings(\"resource\")\n\tpublic static void main(String[] args) {\n\t\tApplicationContext ctxObj = new ClassPathXmlApplicationContext(\"applicationContext.xml\");  \n\t\tTechEditorDao daoObj = (TechEditorDao)ctxObj.getBean(\"techDao\");\n\n\t\t\/\/ This Method Is Used To Fetch Records From The Db\n\t\tList editorList = daoObj.getAllEditors();\n\t\tfor(TechEditor techEditorObj : editorList) {\n\t\t\tSystem.out.println(techEditorObj.toString());\n\t\t}\n\t}\n}\n<\/pre>\n<h4>3.4 Spring Configuration File<\/h4>\n<p>Spring loads <code>applicationContext.xml<\/code> file and creates the <code>ApplicationContext<\/code> which provides the configuration information to an application. This interface provides standard bean factory lifecycle capabilities. In this file,<\/p>\n<ul>\n<li>The <code>DriverManagerDataSource<\/code> contains the information about the database such as driver class name, connection URL, username and password.<\/li>\n<li>A property named <code>dataSource<\/code> in the <code>JdbcTemplate<\/code> class of <code>org.springframework.jdbc.datasource.DriverManagerDataSource<\/code> type.<\/li>\n<\/ul>\n<p>To configure the spring framework, we need to implement a configuration file i.e. <code>applicationContext.xml<\/code>. Right click on <code>src\/main\/resources<\/code> folder, <code>New -&gt; Other<\/code>.<\/p>\n<p><figure id=\"attachment_48858\" aria-describedby=\"caption-attachment-48858\" style=\"width: 704px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-result-set-extractor-spring-configuration-guide-1.jpg\"><img decoding=\"async\" class=\"size-full wp-image-48858\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-result-set-extractor-spring-configuration-guide-1.jpg\" alt=\"Fig. 12: Xml File Creation\" width=\"704\" height=\"659\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-result-set-extractor-spring-configuration-guide-1.jpg 704w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-result-set-extractor-spring-configuration-guide-1-300x281.jpg 300w\" sizes=\"(max-width: 704px) 100vw, 704px\" \/><\/a><figcaption id=\"caption-attachment-48858\" class=\"wp-caption-text\">Fig. 12: XML File Creation<\/figcaption><\/figure><\/p>\n<p>A new pop window will open and select the wizard as the XML file.<\/p>\n<p><figure id=\"attachment_48859\" aria-describedby=\"caption-attachment-48859\" style=\"width: 519px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-result-set-extractor-spring-configuration-guide-2.jpg\"><img decoding=\"async\" class=\"size-full wp-image-48859\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-result-set-extractor-spring-configuration-guide-2.jpg\" alt=\"Fig. 13: Wizard Selection\" width=\"519\" height=\"495\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-result-set-extractor-spring-configuration-guide-2.jpg 519w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-result-set-extractor-spring-configuration-guide-2-300x286.jpg 300w\" sizes=\"(max-width: 519px) 100vw, 519px\" \/><\/a><figcaption id=\"caption-attachment-48859\" class=\"wp-caption-text\">Fig. 13: Wizard Selection<\/figcaption><\/figure><\/p>\n<p>Again, a pop-up window will open. Verify the parent folder location as <code>JdbcResultSetExtractor\/src\/main\/resources<\/code> and enter the file name as <code>applicationContext.xml<\/code>. Click Finish.<\/p>\n<p><figure id=\"attachment_48860\" aria-describedby=\"caption-attachment-48860\" style=\"width: 519px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-result-set-extractor-spring-configuration-guide-3.jpg\"><img decoding=\"async\" class=\"size-full wp-image-48860\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-result-set-extractor-spring-configuration-guide-3.jpg\" alt=\"Fig. 14: applicationContext.xml\" width=\"519\" height=\"600\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-result-set-extractor-spring-configuration-guide-3.jpg 519w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-result-set-extractor-spring-configuration-guide-3-260x300.jpg 260w\" sizes=\"(max-width: 519px) 100vw, 519px\" \/><\/a><figcaption id=\"caption-attachment-48860\" class=\"wp-caption-text\">Fig. 14: applicationContext.xml<\/figcaption><\/figure><\/p>\n<p>Once the file is created, add the following code to it:<\/p>\n<p><span style=\"text-decoration: underline;\"><em>applicationContext.xml<\/em><\/span><\/p>\n<pre class=\"brush:xml; wrap-lines:false;\">&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\n&lt;beans xmlns=\"http:\/\/www.springframework.org\/schema\/beans\" xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\" xmlns:p=\"http:\/\/www.springframework.org\/schema\/p\" xsi:schemaLocation=\"http:\/\/www.springframework.org\/schema\/beans http:\/\/www.springframework.org\/schema\/beans\/spring-beans-3.0.xsd\"&gt;\n\n\t&lt;!-- Database Connection Settings --&gt;\n\t&lt;bean id=\"dataSourceObj\" class=\"org.springframework.jdbc.datasource.DriverManagerDataSource\"&gt;\n\t\t&lt;property name=\"driverClassName\" value=\"com.mysql.jdbc.Driver\" \/&gt;\n\t\t&lt;property name=\"url\" value=\"jdbc:mysql:\/\/localhost:3306\/tutorialDb\" \/&gt;\n\t\t&lt;property name=\"username\" value=\"root\" \/&gt;\n\t\t&lt;property name=\"password\" value=\"admin@123\" \/&gt;\n\t&lt;\/bean&gt;\n\n\t&lt;!-- Bean Definition For DataSource --&gt;\n\t&lt;bean id=\"templateObj\" class=\"org.springframework.jdbc.core.JdbcTemplate\"&gt;\n\t\t&lt;property name=\"dataSource\" ref=\"dataSourceObj\" \/&gt;\n\t&lt;\/bean&gt;\n\n\t&lt;!-- Bean Definition For TechEditorDao --&gt;\n\t&lt;bean id=\"techDao\" class=\"com.jdbc.resultset.extractor.TechEditorDao\"&gt;\n\t\t&lt;property name=\"templateObj\" ref=\"templateObj\" \/&gt;\n\t&lt;\/bean&gt;\n&lt;\/beans&gt;\n<\/pre>\n<h2>4. Run the Application<\/h2>\n<p>To run the application, Right click on the <code>JdbcResultSet<\/code> class, <code>Run As -&gt; Java Application<\/code>.<\/p>\n<p><figure id=\"attachment_48861\" aria-describedby=\"caption-attachment-48861\" style=\"width: 792px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-resultset-extractor-example-project-deploy-1.jpg\"><img decoding=\"async\" class=\"size-full wp-image-48861\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-resultset-extractor-example-project-deploy-1.jpg\" alt=\"Fig. 15: Run Application\" width=\"792\" height=\"695\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-resultset-extractor-example-project-deploy-1.jpg 792w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-resultset-extractor-example-project-deploy-1-300x263.jpg 300w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-resultset-extractor-example-project-deploy-1-768x674.jpg 768w\" sizes=\"(max-width: 792px) 100vw, 792px\" \/><\/a><figcaption id=\"caption-attachment-48861\" class=\"wp-caption-text\">Fig. 15: Run Application<\/figcaption><\/figure><\/p>\n<h2>5. Project Demo<\/h2>\n<p>The code shows the following status as output:<\/p>\n<p><figure id=\"attachment_48862\" aria-describedby=\"caption-attachment-48862\" style=\"width: 849px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-result-set-extractor-demo-1.jpg\"><img decoding=\"async\" class=\"size-full wp-image-48862\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-result-set-extractor-demo-1.jpg\" alt=\"Fig. 16: Database Records\" width=\"849\" height=\"116\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-result-set-extractor-demo-1.jpg 849w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-result-set-extractor-demo-1-300x41.jpg 300w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/jdbc-result-set-extractor-demo-1-768x105.jpg 768w\" sizes=\"(max-width: 849px) 100vw, 849px\" \/><\/a><figcaption id=\"caption-attachment-48862\" class=\"wp-caption-text\">Fig. 16: Database Records<\/figcaption><\/figure><\/p>\n<p>That\u2019s all for this post. Happy Learning!!<\/p>\n<h2>6. Conclusion<\/h2>\n<p>Here, we understood what is <code>ResultSetExtractor<\/code> interface and how we can implement the same in Java.<\/p>\n<h2>7. Download the Eclipse Project<\/h2>\n<p>This was an example of JDBC ResultSetExtractor.<\/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\/07\/JdbcResultSetExtractor.zip\" target=\"_blank\" rel=\"noopener noreferrer\"><strong>JdbcResultSetExtractor<\/strong><\/a><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Spring provides a simplification in handling database access with the Spring JDBC Template. The org.springframework.jdbc.core.ResultSetExtractor interface is a callback interface used by JdbcTemplate&#8217;s query methods. Implementations of this interface perform the actual work of extracting results from an&nbsp;SQL ResultSet object. In this article, we will try to show how the ResultSetExtractor mechanism can be applied &hellip;<\/p>\n","protected":false},"author":119,"featured_media":1204,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[53],"tags":[189,216,602,1055],"class_list":["post-48845","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-sql","tag-core-java-2","tag-jdbc-2","tag-resultset","tag-sql"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>JDBC ResultSetExtractor Example - Java Code Geeks<\/title>\n<meta name=\"description\" content=\"In this article, we will try to show how to implement the ResultSetExtractor mechanism can be applied to a Java application.\" \/>\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\/sql\/jdbc-resultsetextractor-example\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"JDBC ResultSetExtractor Example - Java Code Geeks\" \/>\n<meta property=\"og:description\" content=\"In this article, we will try to show how to implement the ResultSetExtractor mechanism can be applied to a Java application.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/sql\/jdbc-resultsetextractor-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-08-02T08:00:08+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2019-03-05T11:05:28+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-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=\"Yatin\" \/>\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=\"Yatin\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"11 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\/sql\/jdbc-resultsetextractor-example\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/sql\/jdbc-resultsetextractor-example\/\"},\"author\":{\"name\":\"Yatin\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/9874407a37b028e8be3276e2b5960d13\"},\"headline\":\"JDBC ResultSetExtractor Example\",\"datePublished\":\"2017-08-02T08:00:08+00:00\",\"dateModified\":\"2019-03-05T11:05:28+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/sql\/jdbc-resultsetextractor-example\/\"},\"wordCount\":1297,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/sql\/jdbc-resultsetextractor-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg\",\"keywords\":[\"core java\",\"jdbc\",\"resultset\",\"sql\"],\"articleSection\":[\"sql\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/sql\/jdbc-resultsetextractor-example\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/sql\/jdbc-resultsetextractor-example\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/sql\/jdbc-resultsetextractor-example\/\",\"name\":\"JDBC ResultSetExtractor Example - Java Code Geeks\",\"isPartOf\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/sql\/jdbc-resultsetextractor-example\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/sql\/jdbc-resultsetextractor-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg\",\"datePublished\":\"2017-08-02T08:00:08+00:00\",\"dateModified\":\"2019-03-05T11:05:28+00:00\",\"description\":\"In this article, we will try to show how to implement the ResultSetExtractor mechanism can be applied to a Java application.\",\"breadcrumb\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/sql\/jdbc-resultsetextractor-example\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/sql\/jdbc-resultsetextractor-example\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/sql\/jdbc-resultsetextractor-example\/#primaryimage\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg\",\"width\":150,\"height\":150,\"caption\":\"Bipartite Graph\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/sql\/jdbc-resultsetextractor-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\":\"sql\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/java-development\/core-java\/sql\/\"},{\"@type\":\"ListItem\",\"position\":5,\"name\":\"JDBC ResultSetExtractor 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\/9874407a37b028e8be3276e2b5960d13\",\"name\":\"Yatin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2023\/09\/cropped-Yatin-Batra_avatar_1515758148-96x96.jpg\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2023\/09\/cropped-Yatin-Batra_avatar_1515758148-96x96.jpg\",\"caption\":\"Yatin\"},\"description\":\"An experience full-stack engineer well versed with Core Java, Spring\/Springboot, MVC, Security, AOP, Frontend (Angular &amp; React), and cloud technologies (such as AWS, GCP, Jenkins, Docker, K8).\",\"sameAs\":[\"https:\/\/www.javacodegeeks.com\"],\"url\":\"https:\/\/examples.javacodegeeks.com\/author\/yatin-batra\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"JDBC ResultSetExtractor Example - Java Code Geeks","description":"In this article, we will try to show how to implement the ResultSetExtractor mechanism can be applied to a Java application.","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\/sql\/jdbc-resultsetextractor-example\/","og_locale":"en_US","og_type":"article","og_title":"JDBC ResultSetExtractor Example - Java Code Geeks","og_description":"In this article, we will try to show how to implement the ResultSetExtractor mechanism can be applied to a Java application.","og_url":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/sql\/jdbc-resultsetextractor-example\/","og_site_name":"Examples Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2017-08-02T08:00:08+00:00","article_modified_time":"2019-03-05T11:05:28+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg","type":"image\/jpeg"}],"author":"Yatin","twitter_card":"summary_large_image","twitter_creator":"@javacodegeeks","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Yatin","Est. reading time":"11 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/sql\/jdbc-resultsetextractor-example\/#article","isPartOf":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/sql\/jdbc-resultsetextractor-example\/"},"author":{"name":"Yatin","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/9874407a37b028e8be3276e2b5960d13"},"headline":"JDBC ResultSetExtractor Example","datePublished":"2017-08-02T08:00:08+00:00","dateModified":"2019-03-05T11:05:28+00:00","mainEntityOfPage":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/sql\/jdbc-resultsetextractor-example\/"},"wordCount":1297,"commentCount":0,"publisher":{"@id":"https:\/\/examples.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/sql\/jdbc-resultsetextractor-example\/#primaryimage"},"thumbnailUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg","keywords":["core java","jdbc","resultset","sql"],"articleSection":["sql"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/sql\/jdbc-resultsetextractor-example\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/sql\/jdbc-resultsetextractor-example\/","url":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/sql\/jdbc-resultsetextractor-example\/","name":"JDBC ResultSetExtractor Example - Java Code Geeks","isPartOf":{"@id":"https:\/\/examples.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/sql\/jdbc-resultsetextractor-example\/#primaryimage"},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/sql\/jdbc-resultsetextractor-example\/#primaryimage"},"thumbnailUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg","datePublished":"2017-08-02T08:00:08+00:00","dateModified":"2019-03-05T11:05:28+00:00","description":"In this article, we will try to show how to implement the ResultSetExtractor mechanism can be applied to a Java application.","breadcrumb":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/sql\/jdbc-resultsetextractor-example\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/sql\/jdbc-resultsetextractor-example\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/sql\/jdbc-resultsetextractor-example\/#primaryimage","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg","width":150,"height":150,"caption":"Bipartite Graph"},{"@type":"BreadcrumbList","@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/sql\/jdbc-resultsetextractor-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":"sql","item":"https:\/\/examples.javacodegeeks.com\/category\/java-development\/core-java\/sql\/"},{"@type":"ListItem","position":5,"name":"JDBC ResultSetExtractor 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\/9874407a37b028e8be3276e2b5960d13","name":"Yatin","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/image\/","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2023\/09\/cropped-Yatin-Batra_avatar_1515758148-96x96.jpg","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2023\/09\/cropped-Yatin-Batra_avatar_1515758148-96x96.jpg","caption":"Yatin"},"description":"An experience full-stack engineer well versed with Core Java, Spring\/Springboot, MVC, Security, AOP, Frontend (Angular &amp; React), and cloud technologies (such as AWS, GCP, Jenkins, Docker, K8).","sameAs":["https:\/\/www.javacodegeeks.com"],"url":"https:\/\/examples.javacodegeeks.com\/author\/yatin-batra\/"}]}},"_links":{"self":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/48845","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\/119"}],"replies":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=48845"}],"version-history":[{"count":0,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/48845\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/media\/1204"}],"wp:attachment":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/media?parent=48845"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=48845"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=48845"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}