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.CallableStatement;
20: import java.sql.SQLException;
21:
22: /**
23: * Interface to be implemented for retrieving values for more complex database-specific
24: * types not supported by the standard <code>CallableStatement.getObject</code> method.
25: *
26: * <p>Implementations perform the actual work of getting the actual values. They must
27: * implement the callback method <code>getTypeValue</code> which can throw SQLExceptions
28: * that will be caught and translated by the calling code. This callback method has
29: * access to the underlying Connection via the given CallableStatement object, if that
30: * should be needed to create any database-specific objects.
31: *
32: * @author Thomas Risberg
33: * @since 1.1
34: * @see java.sql.Types
35: * @see java.sql.CallableStatement#getObject
36: * @see org.springframework.jdbc.object.StoredProcedure#execute(java.util.Map)
37: */
38: public interface SqlReturnType {
39:
40: /**
41: * Constant that indicates an unknown (or unspecified) SQL type.
42: * Passed into setTypeValue if the original operation method does
43: * not specify a SQL type.
44: * @see java.sql.Types
45: * @see JdbcOperations#update(String, Object[])
46: */
47: int TYPE_UNKNOWN = Integer.MIN_VALUE;
48:
49: /**
50: * Get the type value from the specific object.
51: * @param cs the CallableStatement to operate on
52: * @param paramIndex the index of the parameter for which we need to set the value
53: * @param sqlType SQL type of the parameter we are setting
54: * @param typeName the type name of the parameter
55: * @return the target value
56: * @throws SQLException if a SQLException is encountered setting parameter values
57: * (that is, there's no need to catch SQLException)
58: * @see java.sql.Types
59: * @see java.sql.CallableStatement#getObject
60: */
61: Object getTypeValue(CallableStatement cs, int paramIndex,
62: int sqlType, String typeName) throws SQLException;
63:
64: }
|