Get Auto-generated Id in Spring JDBC using SimpleJdbcInsert

Auro-generated Id In this post I will show you how to get auto generated id of a newly inserted row in table. Spring provides an easy way to get this auto-generated key using executeAndReturnKey() method of SimpleJdbcInsert which is supported Spring JDBC 3 onwards. For most of the records I will use auto generated Id value on database side to…

Auto-generated Id In Spring JDBC Using PreparedStatement

Generated Id In this post I will show you how to get auto generated id of a newly inserted row in table. Spring provides an easy way to get this auto-generated key using KeyHolder which is supported Spring JDBC 3 onward. I am going to use PreparedStatement to get the auto generated id value. For most of the records, I…

Select Single and Multiple Records using Spring JdbcTemplate

Record Selection 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…

Single and Multiple Records Insert using Spring JdbcTemplate

Records Insertion Using Spring Jdbc Template 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…

Define Multiple DataSources in Spring

Introduction This tutorial will show you how you can get a list of data sources using Spring framework. I will define multiple datasources in Spring. There may be situations where you need to define multiple datasources in Spring application. Why do you need multiple DataSource? You might need to connect to multiple different databases from your same application. Then you…

Batch Insert using Spring JdbcTemplate

This tutorial will show you how you can insert a large dataset or perform batch insert into a database at once using Spring JdbcTemplate. Sometimes you need to insert or update large number of records in the database. It’s not a good idea to insert multiple records into database one by one in a traditional approach. It will hit the…