JdbcTemplate to execute SQL DML Statements
- Thursday, October 27, 2011, 8:35
- Spring Framework, Spring JDBC
- Add a comment
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….

