

{"id":19408,"date":"2018-06-27T04:10:42","date_gmt":"2018-06-27T04:10:42","guid":{"rendered":"https:\/\/data-flair.training\/blogs\/?p=19408"},"modified":"2018-09-15T12:27:23","modified_gmt":"2018-09-15T06:57:23","slug":"spring-jdbc","status":"publish","type":"post","link":"https:\/\/data-flair.training\/blogs\/spring-jdbc\/","title":{"rendered":"Spring JDBC Framework &#8211; JDBCTemplate with Eclipse IDE"},"content":{"rendered":"<h2 class=\"western\">1. Objective<\/h2>\n<p>In our last tutorial, we saw <strong><a href=\"https:\/\/data-flair.training\/blogs\/spring-mvc-framework\/\">Spring MVC Framework<\/a><\/strong>. In this Spring JDBC Tutorial, we are going to discuss Spring JDBCTemplate with Eclipse IDE.\u00a0Using plain old JDBC for working with a database, it becomes complicated to use an unnecessary code for opening\/closing database or handle exceptions etc.<br \/>\nSo, let&#8217;s start Spring JDBC Framework Tutorial.<\/p>\n<div id=\"attachment_19418\" style=\"width: 1210px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/06\/Spring-JDBC-Framework-01.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-19418\" class=\"wp-image-19418 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/06\/Spring-JDBC-Framework-01.jpg\" alt=\"Spring JDBC Framework - JDBCTemplate with Eclipse IDE\" width=\"1200\" height=\"628\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/06\/Spring-JDBC-Framework-01.jpg 1200w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/06\/Spring-JDBC-Framework-01-150x79.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/06\/Spring-JDBC-Framework-01-300x157.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/06\/Spring-JDBC-Framework-01-768x402.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/06\/Spring-JDBC-Framework-01-1024x536.jpg 1024w\" sizes=\"auto, (max-width: 1200px) 100vw, 1200px\" \/><\/a><p id=\"caption-attachment-19418\" class=\"wp-caption-text\">Spring JDBC Framework &#8211; JDBCTemplate with Eclipse IDE<\/p><\/div>\n<h2>2. Spring JDBC Framework<\/h2>\n<p>Spring JDBC gives several approaches and different classes to use it with the database. So, you just have to define the connection parameters. Also, specify the SQL statement along with doing required work for each iteration while fetching the data.<br \/>\nHere in this Spring JDBC tutorial, you will be seeing the most popular approach which uses JDBC Template class. It is a central framework class which manages all database communication such as executing SQL, updating statements etc. Also, it catches exceptions of JDBC and translates them to generic exception hierarchy defined in package org.framework.dao.<br \/>\n<strong><a href=\"https:\/\/data-flair.training\/blogs\/spring-framework-architecture\/\">Lets Explore Spring Framework Architecture with 4 Modules<\/a><\/strong><br \/>\nThe instances of JdbcTemplate are threaded safe once they are configured. Therefore, you can configure a single instance and then safely inject his into multiple DAOs. A common practice that is done while using Jdbctemplate class is to configure DataSource in Spring config file. Then dependency-inject that into your DAO classes and the JdbcTemplate is created in setter for DataSource.<\/p>\n<h3 class=\"western\">a. Configuration of DataSource<\/h3>\n<p>You will now see how to configure the DataSource with an example. Assuming that you are able to work with MySQL database or any database in which you can change DLL and SQL queries accordingly. Create a database TEST having table STUDENT inside it.<\/p>\n<pre class=\"EnlighterJSRAW\">CREATE TABLE Student(\r\n   ID   INT NOT NULL AUTO_INCREMENT,\r\n   NAME VARCHAR(20) NOT NULL,\r\n   AGE  INT NOT NULL,\r\n   PRIMARY KEY (ID)\r\n);<\/pre>\n<p>The next step is to supply DataSource to JdbcTemplate class so it can configure itself for database access. You can do that in XML file with the following code:<\/p>\n<pre class=\"EnlighterJSRAW\">&lt;bean id = \"dataSource\"\r\nclass = \"org.springframework.jdbc.datasource.DriverManagerDataSource\"&gt;\r\n&lt;property name = \"driverClassName\" value = \"com.mysql.jdbc.Driver\"\/&gt;\r\n&lt;property name = \"url\" value = \"jdbc:mysql:\/\/localhost:3306\/TEST\"\/&gt;\r\n&lt;property name = \"username\" value = \"root\"\/&gt;\r\n&lt;property name = \"password\" value = \"password\"\/&gt;\r\n&lt;\/bean&gt;<\/pre>\n<p>This will configure your DataSource.<br \/>\n<strong><a href=\"https:\/\/data-flair.training\/blogs\/spring-framework-environment-setup\/\">Read About Spring Framework Environment Setup<\/a><\/strong><\/p>\n<h3 class=\"western\">b. Data Access Object (DAO)<\/h3>\n<p>Data Access Object also called DAO is commonly used for database interaction. It provides a means to read\/write data to a database. They should use this functionality through an interface using which rest of application will access them.<br \/>\nThis DAO support in Spring makes it easy to work with technologies like JDBC, Hibernate etc which are used for data access.<\/p>\n<h3 class=\"western\">c. Executing SQL Statements<\/h3>\n<p>Now you will see how to perform Create, Read, Update and Delete operations on database tables using SQL and JdbcTemplate object.<\/p>\n<ul>\n<li><strong>Query for Integer<\/strong><\/li>\n<\/ul>\n<pre class=\"EnlighterJSRAW\">String SQL = \"select count(*) from Student\";\r\nint rowCount = jdbcTemplateObject.queryForInt( SQL );<\/pre>\n<ul>\n<li><strong>Query for String<\/strong><\/li>\n<\/ul>\n<pre class=\"EnlighterJSRAW\">String SQL = \"select name from Student where id = ?\";\r\nString name = jdbcTemplateObject.queryForObject(SQL, new object[]{10}, String.class);<\/pre>\n<ul>\n<li><strong>Query for Long<\/strong><\/li>\n<\/ul>\n<pre class=\"EnlighterJSRAW\">String SQL = \"select count(*) from Student\";\r\nlong rowCount = jdbcTemplateObject.queryForLong( SQL );<\/pre>\n<ul>\n<li><strong>Querying and returning an object<\/strong><\/li>\n<\/ul>\n<pre class=\"EnlighterJSRAW\">String SQL = \"select * from Student where id = ?\";\r\nStudent student = jdbcTemplateObject.queryForObject(\r\nSQL, new Object[]{10}, new StudentMapper());\r\npublic class StudentMapper implements RowMapper&lt;Student&gt; {\r\npublic Student mapRow(ResultSet rs, int rowNum) throws SQLException {\r\nStudent student = new Student();\r\nstudent.setID(rs.getInt(\"id\"));\r\nstudent.setName(rs.getString(\"name\"));\r\nstudent.setAge(rs.getInt(\"age\"));\r\nreturn student;\r\n}\r\n}<\/pre>\n<ul>\n<li><strong>Querying and returning multiple objects<\/strong><\/li>\n<\/ul>\n<pre class=\"EnlighterJSRAW\">String SQL = \"select * from Student\";\r\nList&lt;Student&gt; students = jdbcTemplateObject.query(\r\nSQL, new StudentMapper());\r\npublic class StudentMapper implements RowMapper&lt;Student&gt; {\r\npublic Student mapRow(ResultSet rs, int rowNum) throws SQLException {\r\nStudent student = new Student();\r\nstudent.setID(rs.getInt(\"id\"));\r\nstudent.setName(rs.getString(\"name\"));\r\nstudent.setAge(rs.getInt(\"age\"));\r\nreturn student;\r\n}\r\n}<\/pre>\n<ul>\n<li><strong>Inserting of a row into a table<\/strong><\/li>\n<\/ul>\n<pre class=\"EnlighterJSRAW\">String SQL = \"insert into Student (name, age) values (?, ?)\";\r\njdbcTemplateObject.update( SQL, new Object[]{\"ABC\", 41} );<\/pre>\n<ul>\n<li><strong>Updating a row into a table<\/strong><\/li>\n<\/ul>\n<pre class=\"EnlighterJSRAW\">String SQL = \"update Student set name = ? where id = ?\";\r\njdbcTemplateObject.update( SQL, new Object[]{\"ABC\", 41} );<\/pre>\n<ul>\n<li><strong>Deleting a row from a table<\/strong><\/li>\n<\/ul>\n<pre class=\"EnlighterJSRAW\">String SQL = \"delete Student where id = ?\";\r\njdbcTemplateObject.update( SQL, new Object[]{10} );<\/pre>\n<p class=\"western\"><strong><a href=\"https:\/\/data-flair.training\/blogs\/spring-logging\/\">Read About Integration of Spring Logging with log4j \u2013 Eclipse IDE Coding<\/a><\/strong><\/p>\n<h3 class=\"western\">d. Executing DDL Statements<\/h3>\n<p>You can use execute() from JdbcTemplate to execute any SQL or DDL statements. See the below example to use CREATE statement for table creation:<\/p>\n<pre class=\"EnlighterJSRAW\">String SQL = \"CREATE TABLE Student( \" +\r\n\"ID INT NOT NULL AUTO_INCREMENT, \" +\r\n\"NAME VARCHAR(20) NOT NULL, \" +\r\n\"AGE INT NOT NULL, \" +\r\n\"PRIMARY KEY (ID));\"\r\njdbcTemplateObject.execute( SQL );<\/pre>\n<h3 class=\"western\">e. Working Example for JDBC Template<\/h3>\n<p>Here let\u2019s define an example for getting a better understanding of Spring JDBC framework. Eclipse IDE is used for coding.<br \/>\nBefore defining let\u2019s see the steps that are required:<\/p>\n<ol>\n<li>Create your project with name SpringEx and a package com.example. This should be under the src folder of your created project.<\/li>\n<li>Add the Spring Libraries that are required using the Add External JARs options.<\/li>\n<li>Add JDBC libraries mysql-connector-java.jar, org.springframework.jdbc.jar and org.springframework.transaction.jar in your project.<\/li>\n<li>List down all the methods for DAO interface StudentDAO.<\/li>\n<li>Create other classes Student<i>.java<\/i>, StudentMapper.java, StudentJDBCTemplate.java and MainApp.java.<\/li>\n<li>Create bean config file Beans.xml under src.<\/li>\n<li>Finally, write code for all <a href=\"https:\/\/data-flair.training\/blogs\/java-file-class\/\"><strong>Java files<\/strong><\/a> and Bean config file and run the application as described.<\/li>\n<\/ol>\n<p>The Student table which was created above will be used for explanation.<br \/>\nFollowing is code for StudentDAO.java file:<\/p>\n<pre class=\"EnlighterJSRAW\">package com.example;\r\nimport java.util.List;\r\nimport javax.sql.DataSource;\r\npublic interface StudentDAO {\r\n\/**\r\n* This is to be used to initialize\r\n* databaseconnection.\r\n*\/\r\npublic void setDataSource(DataSource ds);\r\n\/**\r\n* This is to be used to create\r\n* a record in Student table.\r\n*\/\r\npublic void create(String name, Integer age);\r\n\/**\r\n* This is to be used to list down\r\n* a record from the Student table corresponding\r\n* to a passed student id.\r\n*\/\r\npublic Student getStudent(Integer id);\r\n\/**\r\n* This is to be used to list down\r\n* all the records from the Student table.\r\n*\/\r\npublic List&lt;Student&gt; listStudents();\r\n\/**\r\n* This is to be used to delete\r\n* a record from the Student table corresponding\r\n* to a passed student id.\r\n*\/\r\npublic void delete(Integer id);\r\n\/**\r\n* This is to be used to update\r\n* a record into the Student table.\r\n*\/\r\npublic void update(Integer id, Integer age);\r\n}<\/pre>\n<h4>i. Now write the below Student.Java:<\/h4>\n<pre class=\"EnlighterJSRAW\">package com.example;\r\npublic class Student {\r\nprivate Integer age;\r\nprivate String name;\r\nprivate Integer id;\r\npublic void setAge(Integer age) {\r\nthis.age = age;\r\n}\r\npublic Integer getAge() {\r\nreturn age;\r\n}\r\npublic void setName(String name) {\r\nthis.name = name;\r\n}\r\npublic String getName() {\r\nreturn name;\r\n}\r\npublic void setId(Integer id) {\r\nthis.id = id;\r\n}\r\npublic Integer getId() {\r\nreturn id;\r\n}\r\n}<\/pre>\n<p><strong><a href=\"https:\/\/data-flair.training\/blogs\/spring-mvc-framework\/\">Let&#8217;s Learn Integration of MVC with Spring Framework<\/a><\/strong><\/p>\n<h4>ii. Following is the code for StudentMapper.Java:<\/h4>\n<pre class=\"EnlighterJSRAW\">package com.example;\r\nimport java.sql.ResultSet;\r\nimport java.sql.SQLException;\r\nimport org.springframework.jdbc.core.RowMapper;\r\npublic class StudentMapper implements RowMapper&lt;Student&gt; {\r\npublic Student mapRow(ResultSet rs, int rowNum) throws SQLException {\r\nStudent student = new Student();\r\nstudent.setId(rs.getInt(\"id\"));\r\nstudent.setName(rs.getString(\"name\"));\r\nstudent.setAge(rs.getInt(\"age\"));\r\nreturn student;\r\n}\r\n}<\/pre>\n<h4>iii. Implement this class file<\/h4>\n<p>For the DAO interface StudentDAO use the following implementation class file StudentJDBCTemplate.java:<\/p>\n<pre class=\"EnlighterJSRAW\">package com.example;\r\nimport java.util.List;\r\nimport javax.sql.DataSource;\r\nimport org.springframework.jdbc.core.JdbcTemplate;\r\npublic class StudentJDBCTemplate implements StudentDAO {\r\nprivate DataSource dataSource;\r\nprivate JdbcTemplate jdbcTemplateObject;\r\npublic void setDataSource(DataSource dataSource) {\r\nthis.dataSource = dataSource;\r\nthis.jdbcTemplateObject = new JdbcTemplate(dataSource);\r\n}\r\npublic void create(String name, Integer age) {\r\nString SQL = \"insert into Student (name, age) values (?, ?)\";\r\njdbcTemplateObject.update( SQL, name, age);\r\nSystem.out.println(\"Created Record Name = \" + name + \" Age = \" + age);\r\nreturn;\r\n}\r\npublic Student getStudent(Integer id) {\r\nString SQL = \"select * from Student where id = ?\";\r\nStudent student = jdbcTemplateObject.queryForObject(SQL,\r\nnew Object[]{id}, new StudentMapper());\r\nreturn student;\r\n}\r\npublic List&lt;Student&gt; listStudents() {\r\nString SQL = \"select * from Student\";\r\nList &lt;Student&gt; students = jdbcTemplateObject.query(SQL, new StudentMapper());\r\nreturn students;\r\n}\r\npublic void delete(Integer id) {\r\nString SQL = \"delete from Student where id = ?\";\r\njdbcTemplateObject.update(SQL, id);\r\nSystem.out.println(\"Deleted Record with ID = \" + id );\r\nreturn;\r\n}\r\npublic void update(Integer id, Integer age){\r\nString SQL = \"update Student set age = ? where id = ?\";\r\njdbcTemplateObject.update(SQL, age, id);\r\nSystem.out.println(\"Updated Record with ID = \" + id );\r\nreturn;\r\n}\r\n}<\/pre>\n<h4>iv.\u00a0 Now the code for MainApp.java is as shown:<\/h4>\n<pre class=\"EnlighterJSRAW\">package com.example;\r\nimport java.util.List;\r\nimport org.springframework.context.ApplicationContext;\r\nimport org.springframework.context.support.ClassPathXmlApplicationContext;\r\nimport com.example.StudentJDBCTemplate;\r\npublic class MainApp {\r\npublic static void main(String[] args) {\r\nApplicationContext context = new ClassPathXmlApplicationContext(\"Beans.xml\");\r\nStudentJDBCTemplate studentJDBCTemplate =\r\n(StudentJDBCTemplate)context.getBean(\"studentJDBCTemplate\");\r\nSystem.out.println(\"------Records Creation--------\" );\r\nstudentJDBCTemplate.create(\"Hari\", 11);\r\nstudentJDBCTemplate.create(\"Nuha\", 2);\r\nstudentJDBCTemplate.create(\"Ayan\", 15);\r\nSystem.out.println(\"------Listing Multiple Records--------\" );\r\nList&lt;Student&gt; students = studentJDBCTemplate.listStudents();\r\nfor (Student record: students) {\r\nSystem.out.print(\"ID : \" + record.getId() );\r\nSystem.out.print(\", Name : \" + record.getName() );\r\nSystem.out.println(\", Age : \" + record.getAge());\r\n}\r\nSystem.out.println(\"----Updating Record with ID = 2 -----\" );\r\nstudentJDBCTemplate.update(2, 20);\r\nSystem.out.println(\"----Listing Record with ID = 2 -----\" );\r\nStudent student = studentJDBCTemplate.getStudent(2);\r\nSystem.out.print(\"ID : \" + student.getId() );\r\nSystem.out.print(\", Name : \" + student.getName() );\r\nSystem.out.println(\", Age : \" + student.getAge());\r\n}\r\n}<\/pre>\n<h4>v. Now you will write the Beans.xml:<\/h4>\n<pre class=\"EnlighterJSRAW\">&lt;?xml version = \"1.0\" encoding = \"UTF-8\"?&gt;\r\n&lt;beans xmlns = \"http:\/\/www.springframework.org\/schema\/beans\"\r\nxmlns:xsi = \"http:\/\/www.w3.org\/2001\/XMLSchema-instance\"\r\nxsi:schemaLocation = \"http:\/\/www.springframework.org\/schema\/beans\r\nhttp:\/\/www.springframework.org\/schema\/beans\/spring-beans-3.0.xsd \"&gt;\r\n&lt;!-- Initialization for data source --&gt;\r\n&lt;bean id=\"dataSource\"\r\nclass = \"org.springframework.jdbc.datasource.DriverManagerDataSource\"&gt;\r\n&lt;property name = \"driverClassName\" value = \"com.mysql.jdbc.Driver\"\/&gt;\r\n&lt;property name = \"url\" value = \"jdbc:mysql:\/\/localhost:3306\/TEST\"\/&gt;\r\n&lt;property name = \"username\" value = \"root\"\/&gt;\r\n&lt;property name = \"password\" value = \"password\"\/&gt;\r\n&lt;\/bean&gt;\r\n&lt;!-- Definition for studentJDBCTemplate bean --&gt;\r\n&lt;bean id = \"studentJDBCTemplate\"\r\nclass = \"com.example.StudentJDBCTemplate\"&gt;\r\n&lt;property name = \"dataSource\" ref = \"dataSource\" \/&gt;\r\n&lt;\/bean&gt;\r\n&lt;\/beans&gt;<\/pre>\n<p>Finally, if you get all the things correctly then you will get the following as your output:<br \/>\n<strong>&#8212;&#8212;Records Creation&#8212;&#8212;&#8211;<\/strong><br \/>\n<strong>Created Record Name = Hari Age = 11<\/strong><br \/>\n<strong>Created Record Name = Nuha Age = 2<\/strong><br \/>\n<strong>Created Record Name = Ayan Age = 15<\/strong><br \/>\n<strong>&#8212;&#8212;Listing Multiple Records&#8212;&#8212;&#8211;<\/strong><br \/>\n<strong>ID : 1, Name : Hari, Age : 11<\/strong><br \/>\n<strong>ID : 2, Name : Nuha, Age : 2<\/strong><br \/>\n<strong>ID : 3,<\/strong> <strong>Name: Ayan, Age: 15<\/strong><br \/>\n<strong>&#8212;-Updating Record with ID = 2 &#8212;&#8211;<\/strong><br \/>\n<strong>Updated Record with ID = 2<\/strong><br \/>\n<strong>&#8212;-Listing Record with ID = 2 &#8212;&#8211;<\/strong><br \/>\n<strong>ID : 2, Name : Nuha, Age : 20<\/strong><br \/>\nSo, this was all about Spring JDBC Framework Tutorial. Hope you like our explanation.<\/p>\n<h2 class=\"western\">3. Conclusion<\/h2>\n<p>Hence, in this Spring JDBC Tutorial, you learned about the Spring JDBC Framework and how it takes care of all the details. You saw a working example using Eclipse IDE with details for every step. You also saw how Spring JDBC gives several approaches and different classes to use it with the database. If you have any query, feel free to ask in the comment section.<br \/>\nRelated Topic-<a href=\"https:\/\/data-flair.training\/blogs\/spring-java-based-configuration\/\">\u00a0<strong>How to Configure Spring Beans<\/strong><\/a><br \/>\n<strong><a href=\"https:\/\/en.wikipedia.org\/wiki\/Spring_Framework\">For reference<\/a><\/strong><span hidden class=\"__iawmlf-post-loop-links\" data-iawmlf-links=\"[{&quot;id&quot;:1901,&quot;href&quot;:&quot;https:\\\/\\\/en.wikipedia.org\\\/wiki\\\/Spring_Framework&quot;,&quot;archived_href&quot;:&quot;http:\\\/\\\/web-wp.archive.org\\\/web\\\/20251003105514\\\/https:\\\/\\\/en.wikipedia.org\\\/wiki\\\/Spring_Framework&quot;,&quot;redirect_href&quot;:&quot;&quot;,&quot;checks&quot;:[{&quot;date&quot;:&quot;2025-12-10 07:30:46&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2025-12-15 12:34:55&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2025-12-19 00:53:54&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2025-12-22 07:31:03&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2025-12-28 18:03:16&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-01-02 18:56:25&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-01-05 21:42:16&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-01-11 11:07:56&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-01-18 16:10:39&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-01-24 11:15:10&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-02 10:03:18&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-06 11:15:36&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-11 05:03:27&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-16 13:02:34&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-21 05:52:52&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-25 03:33:37&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-03 07:27:11&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-15 08:39:30&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-18 09:30:46&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-04-01 17:30:57&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-04-11 21:45:34&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-04-16 07:00:58&quot;,&quot;http_code&quot;:503},{&quot;date&quot;:&quot;2026-04-21 06:40:46&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-04-24 15:27:59&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-04-27 16:08:07&quot;,&quot;http_code&quot;:429},{&quot;date&quot;:&quot;2026-04-30 17:25:41&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-05-06 03:04:02&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-05-14 20:58:34&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-05-18 03:05:48&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-05-21 18:04:49&quot;,&quot;http_code&quot;:429},{&quot;date&quot;:&quot;2026-05-25 06:08:23&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-06-02 05:46:48&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-06-10 06:21:50&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-06-17 03:52:56&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-06-21 01:38:50&quot;,&quot;http_code&quot;:404}],&quot;broken&quot;:false,&quot;last_checked&quot;:{&quot;date&quot;:&quot;2026-06-21 01:38:50&quot;,&quot;http_code&quot;:404},&quot;process&quot;:&quot;done&quot;}]\"><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>1. Objective In our last tutorial, we saw Spring MVC Framework. In this Spring JDBC Tutorial, we are going to discuss Spring JDBCTemplate with Eclipse IDE.\u00a0Using plain old JDBC for working with a database,&#46;&#46;&#46;<\/p>\n","protected":false},"author":5,"featured_media":19418,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[64],"tags":[2872,3274,4111,4451,4453,4516,13322,13337,13338,13339,13340,13395],"class_list":["post-19408","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-spring","tag-configuration-of-datasource","tag-data-access-object","tag-eclipse-ide","tag-executing-ddl-statements","tag-executing-sql-statements","tag-f-jdbctemplate","tag-spring-framework-jdbc","tag-spring-jdbc","tag-spring-jdbc-framework","tag-spring-jdbc-framework-tutorial","tag-spring-jdbc-tutorial","tag-springdao"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.8 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Spring JDBC Framework - JDBCTemplate with Eclipse IDE - DataFlair<\/title>\n<meta name=\"description\" content=\"Spring JDBC Tutorial- Spring JDBC Framework, JDBC Template with Eclipse IDE Example, Executing DDL Statements, Working Example for JDBC Template, Spring DAO\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/data-flair.training\/blogs\/spring-jdbc\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Spring JDBC Framework - JDBCTemplate with Eclipse IDE - DataFlair\" \/>\n<meta property=\"og:description\" content=\"Spring JDBC Tutorial- Spring JDBC Framework, JDBC Template with Eclipse IDE Example, Executing DDL Statements, Working Example for JDBC Template, Spring DAO\" \/>\n<meta property=\"og:url\" content=\"https:\/\/data-flair.training\/blogs\/spring-jdbc\/\" \/>\n<meta property=\"og:site_name\" content=\"DataFlair\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/DataFlairWS\/\" \/>\n<meta property=\"article:published_time\" content=\"2018-06-27T04:10:42+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2018-09-15T06:57:23+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/06\/Spring-JDBC-Framework-01.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"628\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"DataFlair Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:site\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"DataFlair Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"9 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Spring JDBC Framework - JDBCTemplate with Eclipse IDE - DataFlair","description":"Spring JDBC Tutorial- Spring JDBC Framework, JDBC Template with Eclipse IDE Example, Executing DDL Statements, Working Example for JDBC Template, Spring DAO","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:\/\/data-flair.training\/blogs\/spring-jdbc\/","og_locale":"en_US","og_type":"article","og_title":"Spring JDBC Framework - JDBCTemplate with Eclipse IDE - DataFlair","og_description":"Spring JDBC Tutorial- Spring JDBC Framework, JDBC Template with Eclipse IDE Example, Executing DDL Statements, Working Example for JDBC Template, Spring DAO","og_url":"https:\/\/data-flair.training\/blogs\/spring-jdbc\/","og_site_name":"DataFlair","article_publisher":"https:\/\/www.facebook.com\/DataFlairWS\/","article_published_time":"2018-06-27T04:10:42+00:00","article_modified_time":"2018-09-15T06:57:23+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/06\/Spring-JDBC-Framework-01.jpg","type":"image\/jpeg"}],"author":"DataFlair Team","twitter_card":"summary_large_image","twitter_creator":"@DataFlairWS","twitter_site":"@DataFlairWS","twitter_misc":{"Written by":"DataFlair Team","Est. reading time":"9 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/data-flair.training\/blogs\/spring-jdbc\/#article","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/spring-jdbc\/"},"author":{"name":"DataFlair Team","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/7f83c342f5d1632d6f7b4b0b0f447823"},"headline":"Spring JDBC Framework &#8211; JDBCTemplate with Eclipse IDE","datePublished":"2018-06-27T04:10:42+00:00","dateModified":"2018-09-15T06:57:23+00:00","mainEntityOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/spring-jdbc\/"},"wordCount":875,"commentCount":0,"publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/spring-jdbc\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/06\/Spring-JDBC-Framework-01.jpg","keywords":["Configuration of DataSource","Data Access Object","Eclipse IDE","Executing DDL statements","Executing SQL Statements","f JdbcTemplate","Spring Framework JDBC","Spring JDBC","Spring JDBC Framework","Spring JDBC Framework Tutorial","Spring JDBC Tutorial","SpringDAO"],"articleSection":["Spring Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/data-flair.training\/blogs\/spring-jdbc\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/data-flair.training\/blogs\/spring-jdbc\/","url":"https:\/\/data-flair.training\/blogs\/spring-jdbc\/","name":"Spring JDBC Framework - JDBCTemplate with Eclipse IDE - DataFlair","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/#website"},"primaryImageOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/spring-jdbc\/#primaryimage"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/spring-jdbc\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/06\/Spring-JDBC-Framework-01.jpg","datePublished":"2018-06-27T04:10:42+00:00","dateModified":"2018-09-15T06:57:23+00:00","description":"Spring JDBC Tutorial- Spring JDBC Framework, JDBC Template with Eclipse IDE Example, Executing DDL Statements, Working Example for JDBC Template, Spring DAO","breadcrumb":{"@id":"https:\/\/data-flair.training\/blogs\/spring-jdbc\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/data-flair.training\/blogs\/spring-jdbc\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/spring-jdbc\/#primaryimage","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/06\/Spring-JDBC-Framework-01.jpg","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/06\/Spring-JDBC-Framework-01.jpg","width":1200,"height":628,"caption":"Spring JDBC Framework - JDBCTemplate with Eclipse IDE"},{"@type":"BreadcrumbList","@id":"https:\/\/data-flair.training\/blogs\/spring-jdbc\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog Home","item":"https:\/\/data-flair.training\/blogs\/"},{"@type":"ListItem","position":2,"name":"Reading data from external files","item":"https:\/\/data-flair.training\/blogs\/tag\/reading-data-from-external-files\/"},{"@type":"ListItem","position":3,"name":"Spring JDBC Framework &#8211; JDBCTemplate with Eclipse IDE"}]},{"@type":"WebSite","@id":"https:\/\/data-flair.training\/blogs\/#website","url":"https:\/\/data-flair.training\/blogs\/","name":"DataFlair","description":"Learn Today. Lead Tomorrow.","publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/data-flair.training\/blogs\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/data-flair.training\/blogs\/#organization","name":"DataFlair","url":"https:\/\/data-flair.training\/blogs\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","width":106,"height":48,"caption":"DataFlair"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/DataFlairWS\/","https:\/\/x.com\/DataFlairWS","https:\/\/www.linkedin.com\/company\/dataflair-web-services-pvt-ltd\/","https:\/\/www.youtube.com\/user\/DataFlairWS"]},{"@type":"Person","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/7f83c342f5d1632d6f7b4b0b0f447823","name":"DataFlair Team","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/4cf3a74600d131330b8c481d519afd1574093ed89f6d3396a95393ad223eb7cd?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/4cf3a74600d131330b8c481d519afd1574093ed89f6d3396a95393ad223eb7cd?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/4cf3a74600d131330b8c481d519afd1574093ed89f6d3396a95393ad223eb7cd?s=96&d=mm&r=g","caption":"DataFlair Team"},"description":"DataFlair Team creates expert-level guides on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. Our goal is to empower learners with easy-to-understand content. Explore our resources for career growth and practical learning.","url":"https:\/\/data-flair.training\/blogs\/author\/dfteam1\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/19408","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/comments?post=19408"}],"version-history":[{"count":3,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/19408\/revisions"}],"predecessor-version":[{"id":32601,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/19408\/revisions\/32601"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media\/19418"}],"wp:attachment":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media?parent=19408"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/categories?post=19408"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/tags?post=19408"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}