1 /* 2 * Copyright 2002-2012 the original author or authors. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 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.support; 18 19 import java.sql.PreparedStatement; 20 import java.sql.SQLException; 21 22 /** 23 * Simple interface for complex types to be set as statement parameters. 24 * 25 * <p>Implementations perform the actual work of setting the actual values. They must 26 * implement the callback method {@code setValue} which can throw SQLExceptions 27 * that will be caught and translated by the calling code. This callback method has 28 * access to the underlying Connection via the given PreparedStatement object, if that 29 * should be needed to create any database-specific objects. 30 * 31 * @author Juergen Hoeller 32 * @since 2.5.6 33 * @see org.springframework.jdbc.core.SqlTypeValue 34 * @see org.springframework.jdbc.core.DisposableSqlTypeValue 35 */ 36 public interface SqlValue { 37 38 /** 39 * Set the value on the given PreparedStatement. 40 * @param ps the PreparedStatement to work on 41 * @param paramIndex the index of the parameter for which we need to set the value 42 * @throws SQLException if a SQLException is encountered while setting parameter values 43 */ 44 void setValue(PreparedStatement ps, int paramIndex) throws SQLException; 45 46 /** 47 * Clean up resources held by this value object. 48 */ 49 void cleanup(); 50 51 }