类 AbstractSqlTypeValue
- java.lang.Object
- org.springframework.jdbc.core.support.AbstractSqlTypeValue
- 所有已实现的接口:
SqlTypeValue
public abstract class AbstractSqlTypeValue extends Object implements SqlTypeValue
Abstract implementation of the SqlTypeValue interface, for convenient creation of type values that are supposed to be passed into thePreparedStatement.setObject
method. ThecreateTypeValue
callback method has access to the underlying Connection, if that should be needed to create any database-specific objects.A usage example from a StoredProcedure (compare this to the plain SqlTypeValue version in the superclass javadoc):
proc.declareParameter(new SqlParameter("myarray", Types.ARRAY, "NUMBERS")); ... Map<String, Object> in = new HashMap<String, Object>(); in.put("myarray", new AbstractSqlTypeValue() { public Object createTypeValue(Connection con, int sqlType, String typeName) throws SQLException { oracle.sql.ArrayDescriptor desc = new oracle.sql.ArrayDescriptor(typeName, con); return new oracle.sql.ARRAY(desc, con, seats); } }); Map out = execute(in);
- 从以下版本开始:
- 1.1
- 作者:
- Juergen Hoeller
- 另请参阅:
PreparedStatement.setObject(int, Object, int)
,StoredProcedure
字段概要
从接口继承的字段 org.springframework.jdbc.core.SqlTypeValue
TYPE_UNKNOWN
构造器概要
构造器 构造器 说明 AbstractSqlTypeValue()
方法概要
所有方法 实例方法 抽象方法 具体方法 修饰符和类型 方法 说明 protected abstract Object
createTypeValue(Connection con, int sqlType, String typeName)
Create the type value to be passed intoPreparedStatement.setObject
.void
setTypeValue(PreparedStatement ps, int paramIndex, int sqlType, String typeName)
Set the type value on the given PreparedStatement.
构造器详细资料
AbstractSqlTypeValue
public AbstractSqlTypeValue()
方法详细资料
setTypeValue
public final void setTypeValue(PreparedStatement ps, int paramIndex, int sqlType, @Nullable String typeName) throws SQLException
从接口复制的说明:SqlTypeValue
Set the type value on the given PreparedStatement.- 指定者:
setTypeValue
在接口中SqlTypeValue
- 参数:
ps
- the PreparedStatement to work onparamIndex
- the index of the parameter for which we need to set the valuesqlType
- the SQL type of the parameter we are settingtypeName
- the type name of the parameter (optional)- 抛出:
SQLException
- if an SQLException is encountered while setting parameter values- 另请参阅:
Types
,PreparedStatement.setObject(int, java.lang.Object, int)
createTypeValue
protected abstract Object createTypeValue(Connection con, int sqlType, @Nullable String typeName) throws SQLException
Create the type value to be passed intoPreparedStatement.setObject
.- 参数:
con
- the JDBC Connection, if needed to create any database-specific objectssqlType
- the SQL type of the parameter we are settingtypeName
- the type name of the parameter- 返回:
- the type value
- 抛出:
SQLException
- if an SQLException is encountered setting parameter values (that is, there's no need to catch SQLException)- 另请参阅:
PreparedStatement.setObject(int, Object, int)