Spring Security – JDBC Authentication

In my previous tutorials, I have shown in-memory authentications Spring Security Form based Authentication – XML ConfigurationSpring Security Form based Authentication – Annotations but in this tutorial I will show you how to authenticate user using Spring JDBC and Spring MVC web application to secure pages. I will create spring mvc based web application and I will configure Spring Security to protect a page from outside access.

Spring Security allows to you to integrate security features with JEE web application easily, it takes care about all incoming HTTP requests via servlet filter, and implements “user defined” security checking.

In this tutorial, I will show you how to integrate Spring Security 4.2.1 with Spring MVC4 web application to secure URL access. Continue reading “Spring Security – JDBC Authentication”

Spring @PostConstruct and @PreDestroy Example

This tutorial will show you how we can use @PostConstruct and @PreDestroy in Spring. @PostConstruct and @PreDestroy annotations are generally considered best practice for receiving lifecycle callbacks in a modern Spring application. Using these annotations means that our beans are not coupled to Spring specific interfaces. For more information please refer to http://docs.spring.io/spring-framework/docs/current/spring-framework-reference/html/beans.html#beans-postconstruct-and-predestroy-annotations

Sometimes we need to load some data or perform initialization work after all necessary properties on the bean have been set by the container. In this example we will load data from database during application startup and set that value to a System property so that the value will be set only once and that value can be used later after retrieving from the System property. Continue reading “Spring @PostConstruct and @PreDestroy Example”

Call Stored Procedure using Spring StoredProcedure

This tutorial will show you how we can stored procedure using Spring SimpleJdbcCall. For this tutorial we will create a standalone maven project in Eclipse.

If you already have an idea on how to create a maven project in Eclipse will be great otherwise I will tell you here how to create a maven project in Eclipse.

Sometimes we need to call a stored procedure while a single SQL statement is unable to fulfil our requirements because, it permits to execute multiple SQL statements and it also allows us to execute these SQL statements in a transactional unit in an efficient manner to avoid any inconsistency sometimes occurs during the execution of multiple SQL statements. Continue reading “Call Stored Procedure using Spring StoredProcedure”

Call Stored Procedure using Spring SimpleJdbcCall

This tutorial will show you how we can stored procedure using Spring SimpleJdbcCall. For this tutorial we will create a standalone maven project in Eclipse.

If you already have an idea on how to create a maven project in Eclipse will be great otherwise I will tell you here how to create a maven project in Eclipse.

Sometimes we need to call a stored procedure while a single SQL statement is unable to fulfil our requirements because, it permits to execute multiple SQL statements and it also allows us to execute these SQL statements in a transactional unit in an efficient manner to avoid any inconsistency sometimes occurs during the execution of multiple SQL statements. Continue reading “Call Stored Procedure using Spring SimpleJdbcCall”

Define Multiple DataSources in Spring

This tutorial will show you how we can get a list of data sources using Spring framework. We will define multiple datasources in Spring. There may be situations where we need to define multiple datasources in Spring application.

For this tutorial we will create a standalone maven project in Eclipse.

If you already have an idea on how to create a maven project in Eclipse will be great otherwise I will tell you here how to create a maven project in Eclipse.

Continue reading “Define Multiple DataSources in Spring”

Batch Insert using Spring JdbcTemplate

This tutorial will show you how we can insert a large dataset into a database at once using Spring JdbcTemplate. For this tutorial we will create a standalone maven project in Eclipse.

If you already have an idea on how to create a maven project in Eclipse will be great otherwise I will tell you here how to create a maven project in Eclipse.

Sometimes we 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 application’s performance. Spring provides batch operations with the help of JdbcTemplate, it inserts or updates records into database in one shot. Continue reading “Batch Insert using Spring JdbcTemplate”