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.core; 018 019import java.sql.CallableStatement; 020import java.sql.SQLException; 021 022/** 023 * Interface to be implemented for retrieving values for more complex database-specific 024 * types not supported by the standard {@code CallableStatement.getObject} method. 025 * 026 * <p>Implementations perform the actual work of getting the actual values. They must 027 * implement the callback method {@code getTypeValue} which can throw SQLExceptions 028 * that will be caught and translated by the calling code. This callback method has 029 * access to the underlying Connection via the given CallableStatement object, if that 030 * should be needed to create any database-specific objects. 031 * 032 * @author Thomas Risberg 033 * @since 1.1 034 * @see java.sql.Types 035 * @see java.sql.CallableStatement#getObject 036 * @see org.springframework.jdbc.object.StoredProcedure#execute(java.util.Map) 037 */ 038public interface SqlReturnType { 039 040 /** 041 * Constant that indicates an unknown (or unspecified) SQL type. 042 * Passed into setTypeValue if the original operation method does 043 * not specify a SQL type. 044 * @see java.sql.Types 045 * @see JdbcOperations#update(String, Object[]) 046 */ 047 int TYPE_UNKNOWN = Integer.MIN_VALUE; 048 049 050 /** 051 * Get the type value from the specific object. 052 * @param cs the CallableStatement to operate on 053 * @param paramIndex the index of the parameter for which we need to set the value 054 * @param sqlType SQL type of the parameter we are setting 055 * @param typeName the type name of the parameter 056 * @return the target value 057 * @throws SQLException if a SQLException is encountered setting parameter values 058 * (that is, there's no need to catch SQLException) 059 * @see java.sql.Types 060 * @see java.sql.CallableStatement#getObject 061 */ 062 Object getTypeValue(CallableStatement cs, int paramIndex, int sqlType, String typeName) 063 throws SQLException; 064 065}