Spring Boot MVC and JDBC CRUD Example

Introduction In my other tutorial I had shown how to create an example on Spring MVC and JDBC CRUD example using annotations only, but here I am going to use Spring Boot framework. I did not update the other tutorial keeping in mind if someone still needs the example using Spring framework only. Here also I am going to show you the same example but using Spring Boot framework. We are going to use both gradle and maven build tools to build the application. We are going to see how…

Continue

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

Batch Insertion using Spring JdbcTemplate

Introduction In this post we will see an example on batch insertion using Spring JdbcTemplate. We had seen the similar example using XML configuration previously but here we will create annotation based application. So we will see how we can insert a large data-set into a database at once using Spring JdbcTemplate. 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.…

Continue

Single and Multiple Record Insert using Spring JdbcTemplate

Introduction We will see example on single and multiple insert using Spring JdbcTemplate. We have seen similar example using XML based configuration but here we will see annotation based configuration to insert single or multiple records into database table. We will use here MySQL server 8.0.17 with Spring JdbcTemplate to insert data into database table. We 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 updates records into database in one shot.…

Continue

Spring Security – Authentication and Role Based Authorization using JWT

Introduction In this post we will see an example on Spring Security authentication and role based authorization using JWT (JSON Web Token) on REST or RESTful services. I won’t explain here about JWT as there is already very good article on JWT. We will implement Spring Security’s UserDetailsService to load user from database. We will use Spring JDBC API to perform database operations for fetching or saving user and roles into database. We will use H2 in-memory database to build a quick Spring Boot application. We will also use MySQL…

Continue

Spring Boot Security – Form Based JDBC Authentication using UserDetailsService

Introduction The example Spring Boot Security form based JDBC authentication using UserDetailsService will show you how to use custom login form with Spring’s j_spring_security_check to authenticate a user. You may also look into form based JDBC authentication using UserDetailsService on Spring MVC framework. The similar example we will implement here but using Spring Boot framework. In the previous example we had used Resource Bundle that will also help you to make your application internationalization.

Continue

Spring Boot Security – Form Based JDBC Authentication

Introduction The example, Spring Boot Security form based JDBC authentication, will show you how to use custom login form with Spring’s j_spring_security_check to authenticate a user. You may also look into form based jdbc authentication on Spring MVC framework. The similar example we will implement here but using Spring Boot framework. In the previous example we had used Resource Bundle that will also help you to make your application internationalization.

Continue

How to Create Annotation based Spring Application

Introduction We will see how to create annotation based Spring application or annotation based configuration in Spring application. We will use here H2 database to perform database activities using Spring JDBC Template. We will not use any XML configuration here or zero XML configuration. We will also see how to run this stand-alone Spring application using main method. This application is totally Java based configuration. If you want you can also convert this application as web based application using Spring framework.

Continue

Integrate H2 In-memory Database with Spring

Introduction This tutorial will show you how to integrate in-memory H2 database with Spring. We will see here simple example to understand how it works. Here we will use Spring JDBC API to perform database activities. You can use this example with Spring based applications, such as, Spring Core, Spring MVC etc. You may also like to read Integrate H2 In-memory Database with Spring Boot 2.1. What is an in-memory database? An in memory database is created when an application starts up and destroyed when the application is stopped. Using…

Continue

Define Multiple DataSources in Spring Boot

Introduction This tutorial will show you how you can define multiple datasources in Spring Boot application. I had shown how to define multiple datasources in Spring application, but here I will define multiple datasources in Spring Boot application. There may be situations where you need to define multiple datasources in Spring Boot application. For instance, you may need to define multiple datasources for your Liquibase applications.  You can have different datasource bean ids configured into the Spring configuration class and you can use those datasources as per our needs in the…

Continue