001/* 002 * Copyright 2002-2014 the original author or authors. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * https://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 017package org.springframework.jdbc.core; 018 019import java.sql.PreparedStatement; 020import java.sql.SQLException; 021 022/** 023 * Parameterized callback interface used by the {@link JdbcTemplate} class for 024 * batch updates. 025 * 026 * <p>This interface sets values on a {@link java.sql.PreparedStatement} provided 027 * by the JdbcTemplate class, for each of a number of updates in a batch using the 028 * same SQL. Implementations are responsible for setting any necessary parameters. 029 * SQL with placeholders will already have been supplied. 030 * 031 * <p>Implementations <i>do not</i> need to concern themselves with SQLExceptions 032 * that may be thrown from operations they attempt. The JdbcTemplate class will 033 * catch and handle SQLExceptions appropriately. 034 * 035 * @author Nicolas Fabre 036 * @author Thomas Risberg 037 * @since 3.1 038 * @see JdbcTemplate#batchUpdate(String, java.util.Collection, int, ParameterizedPreparedStatementSetter) 039 */ 040public interface ParameterizedPreparedStatementSetter<T> { 041 042 /** 043 * Set parameter values on the given PreparedStatement. 044 * @param ps the PreparedStatement to invoke setter methods on 045 * @param argument the object containing the values to be set 046 * @throws SQLException if a SQLException is encountered (i.e. there is no need to catch SQLException) 047 */ 048 void setValues(PreparedStatement ps, T argument) throws SQLException; 049 050}