Spring MVC and JDBC CRUD Example

This tutorial shows an example on how MVC(Model, View, Controller) works in Spring 4.x. In this tutorial you will also find how JDBC works with Spring MVC. We will also see how annotation like @Autowired works in Spring. You will also see how datasource is configured in Spring. This example Continue Reading…

Spring NamedParameterJdbcTemplate and Collections.singletonMap Example

In this post I will show you how to use NamedParameterJdbcTemplate and Collections.singletonMap to execute query. The NamedParameterJdbcTemplate class adds support for programming JDBC statements using named parameters, as opposed to programming JDBC statements using only classic placeholder (‘?’) arguments. The NamedParameterJdbcTemplate class wraps a JdbcTemplate, and delegates to the Continue Reading…

Spring NamedParameterJdbcTemplate and BeanPropertySqlParameterSource Example

In this post I will show you how to use NamedParameterJdbcTemplate and BeanPropertySqlParameterSource to execute query. The NamedParameterJdbcTemplate class adds support for programming JDBC statements using named parameters, as opposed to programming JDBC statements using only classic placeholder (‘?’) arguments. The NamedParameterJdbcTemplate class wraps a JdbcTemplate, and delegates to the Continue Reading…

Spring NamedParameterJdbcTemplate and MapSqlParameterSource Example

In this post I will show you how to use NamedParameterJdbcTemplate and MapSqlParameterSource to execute query. The NamedParameterJdbcTemplate class adds support for programming JDBC statements using named parameters, as opposed to programming JDBC statements using only classic placeholder (‘?’) arguments. The NamedParameterJdbcTemplate class wraps a JdbcTemplate, and delegates to the Continue Reading…

Get auto-generated id in Spring JDBC using SimpleJdbcInsert

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 this tutorial we will create a standalone Continue Reading…

Get auto-generated id in Spring JDBC using PreparedStatement

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 onwards. For this tutorial we will create a standalone maven project in Continue Reading…