Javatpoint Logo
Javatpoint Logo

Spring NamedParameterJdbcTemplate Example

Spring provides another way to insert data by named parameter. In such way, we use names instead of ?(question mark). So it is better to remember the data for the column.

Simple example of named parameter query

Method of NamedParameterJdbcTemplate class

In this example,we are going to call only the execute method of NamedParameterJdbcTemplate class. Syntax of the method is as follows:

Example of NamedParameterJdbcTemplate class

We are assuming that you have created the following table inside the Oracle10g database.

This class contains 3 properties with constructors and setter and getters.

It contains on property jdbcTemplate and one method save.


The DriverManagerDataSource is used to contain the information about the database such as driver class name, connnection URL, username and password.

There are a property named datasource in the NamedParameterJdbcTemplate class of DriverManagerDataSource type. So, we need to provide the reference of DriverManagerDataSource object in the NamedParameterJdbcTemplate class for the datasource property.

Here, we are using the NamedParameterJdbcTemplate object in the EmployeeDao class, so we are passing it by the constructor but you can use setter method also.

This class gets the bean from the applicationContext.xml file and calls the save method.

Please Share

facebook twitter google plus pinterest tumbler

Learn Latest Tutorials