01: /*
02: * Copyright 2002-2007 the original author or authors.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16:
17: package org.springframework.jdbc.core;
18:
19: import java.sql.PreparedStatement;
20: import java.sql.SQLException;
21:
22: /**
23: * General callback interface used by the {@link JdbcTemplate} class.
24: *
25: * <p>This interface sets values on a {@link java.sql.PreparedStatement} provided
26: * by the JdbcTemplate class, for each of a number of updates in a batch using the
27: * same SQL. Implementations are responsible for setting any necessary parameters.
28: * SQL with placeholders will already have been supplied.
29: *
30: * <p>It's easier to use this interface than {@link PreparedStatementCreator}:
31: * The JdbcTemplate will create the PreparedStatement, with the callback
32: * only being responsible for setting parameter values.
33: *
34: * <p>Implementations <i>do not</i> need to concern themselves with
35: * SQLExceptions that may be thrown from operations they attempt.
36: * The JdbcTemplate class will catch and handle SQLExceptions appropriately.
37: *
38: * @author Rod Johnson
39: * @since March 2, 2003
40: * @see JdbcTemplate#update(String, PreparedStatementSetter)
41: * @see JdbcTemplate#query(String, PreparedStatementSetter, ResultSetExtractor)
42: */
43: public interface PreparedStatementSetter {
44:
45: /**
46: * Set parameter values on the given PreparedStatement.
47: * @param ps the PreparedStatement to invoke setter methods on
48: * @throws SQLException if a SQLException is encountered
49: * (i.e. there is no need to catch SQLException)
50: */
51: void setValues(PreparedStatement ps) throws SQLException;
52:
53: }
|