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