What is PreparedStatementCreator?
- To write data to database, PreparedStatementCreator is the most commonly used interface. The interface contains one method by name createPreparedStatement(). Returning a PreparedStatement is need when this interface is implemented. Another interface, SqlProvider is also implemented along with this interface, which has a method getSql() for providing sql strings to JdbcTemplate.
Explain about PreparedStatementCreator.
- PreparedStatementCreator is one of the most common used interfaces for writing data to database. The interface has one method createPreparedStatement().
PreparedStatement createPreparedStatement(Connection conn) throws SQLException;
- When this interface is implemented, we should create and return a PreparedStatement from the Connection argument, and the exception handling is automatically taken care off.
- When this interface is implemented, another interface SqlProvider is also implemented which has a method called getSql() which is used to provide sql strings to JdbcTemplate.