JdbcTemplate to execute SQL DML Statements

JdbcTemplate proveides update() methods for executing single SQL DML statement. It support JDBC statement and PreparedStatement style of eecuting the SQL statements.

Following example demonstrates all the update methods of JdbcTemplate. To make this example simple, we are using ‘Product’ table. Following SQL Script show the table description.

Following Dao Interface shows the minimum methods representing the Product table. This Dao containing only the methods to creating , updating and deleting the Product table Records.

You Product bean look likes….

Now write the ProductDaoImpl…

Following code shows the PreparedStatementCreator implementation MyPreparedStatementCreator, which is designed to insert a new Product Records.

Following code is a PreparedStatementSetter implemetation MyPreparedStatementSetter, which is designed to set the Product details for updating the Product.

After writing all the java code, new its time to configure the JdbcTemplate class in Spring XML file.

Now write a client to test that code….

About the Author

has written 22 posts on this blog.

Write a Comment

Gravatars are small images that can show your personality. You can get your gravatar for free today!

Copyright © 2013 JDBC Tutorial. All rights reserved.
Proudly powered by WordPress. Developed by 7tech Solutions