Select Records using queryForObject, queryForList, BeanPropertyRowMapper in Spring JdbcTemplate

Introduction In this post we will see how to select records using queryForObject, queryForList, BeanPropertyRowMapper in Spring JdbcTemplate. Here we will create annotation based example. If you need XML based application then you can refer to the example here. Spring’s queryForObject is used to fetch single row from the database. Spring’s queryForList and BeanPropertyRowMapper are used to fetch multiple rows from the database. Therefore we will fetch single and multiple rows from the database using Spring JdbcTemplate.

Continue

Select Single and Multiple Records using Spring JdbcTemplate

This tutorial will show you how you can select or fetch data from a database using Spring JdbcTemplate. I am going to use Spring Boot framework to select single record, multiple records and only single field or column value from the database. simplifies the use of JDBC and helps to avoid common errors. It executes core JDBC workflow, leaving application code to provide SQL and extract results. This class executes SQL queries or updates, initiating iteration over ResultSets and catching JDBC exceptions and translating them to the generic, more informative…

Continue

Single and Multiple Records Insert using Spring JdbcTemplate

This tutorial will show you how you can insert an object or multiple objects into a database using Spring JdbcTemplate. So you are going to see how to insert single record and multiple records into database table. I am going to use PreparedStatement and BatchPreparedStatementSetter for inserting multiple records. Sometimes you need to insert or update one or few records in the database. You can insert one or multiple records into database one by one in a traditional approach. Spring provides insert operation with the help of JdbcTemplate, it inserts or…

Continue