001/* 002 * Copyright 2002-2012 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.support; 018 019import java.sql.PreparedStatement; 020import java.sql.SQLException; 021 022/** 023 * Simple interface for complex types to be set as statement parameters. 024 * 025 * <p>Implementations perform the actual work of setting the actual values. They must 026 * implement the callback method {@code setValue} which can throw SQLExceptions 027 * that will be caught and translated by the calling code. This callback method has 028 * access to the underlying Connection via the given PreparedStatement object, if that 029 * should be needed to create any database-specific objects. 030 * 031 * @author Juergen Hoeller 032 * @since 2.5.6 033 * @see org.springframework.jdbc.core.SqlTypeValue 034 * @see org.springframework.jdbc.core.DisposableSqlTypeValue 035 */ 036public interface SqlValue { 037 038 /** 039 * Set the value on the given PreparedStatement. 040 * @param ps the PreparedStatement to work on 041 * @param paramIndex the index of the parameter for which we need to set the value 042 * @throws SQLException if a SQLException is encountered while setting parameter values 043 */ 044 void setValue(PreparedStatement ps, int paramIndex) throws SQLException; 045 046 /** 047 * Clean up resources held by this value object. 048 */ 049 void cleanup(); 050 051}