Overview | Package | Class | Tree | Deprecated | Index | Help
| Spring Framework
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.springframework.jdbc.core.support
Class AbstractSqlTypeValue

    java.lang.Object
      org.springframework.jdbc.core.support.AbstractSqlTypeValue

All Implemented Interfaces:
  SqlTypeValue

    public abstract class AbstractSqlTypeValue

extends java.lang.Object
implements SqlTypeValue

Abstract implementation of the SqlTypeValue interface, for convenient creation of type values that are supposed to be passed into the `PreparedStatement.setObject` method. The `createTypeValue` 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);

Since:
  1.1
Author:
  Juergen Hoeller
See Also:
  `PreparedStatement.setObject(int, Object, int)`, `StoredProcedure`

Field Summary

Fields inherited from interface org.springframework.jdbc.core.SqlTypeValue
`TYPE_UNKNOWN`

Constructor Summary
`AbstractSqlTypeValue()`

Method Summary
`protected abstract java.lang.Object` | `createTypeValue(java.sql.Connection con, int sqlType, java.lang.String typeName)` Create the type value to be passed into `PreparedStatement.setObject`.
`void` | `setTypeValue(java.sql.PreparedStatement ps, int paramIndex, int sqlType, java.lang.String typeName)` Set the type value on the given PreparedStatement.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### AbstractSqlTypeValue

    public AbstractSqlTypeValue()

Method Detail

### setTypeValue

    public final void setTypeValue(java.sql.PreparedStatement ps,
                                   int paramIndex,
                                   int sqlType,
                                   java.lang.String typeName)
                            throws java.sql.SQLException

  Description copied from interface: `SqlTypeValue`
  Set the type value on the given PreparedStatement.

  Specified by:
    `setTypeValue` in interface `SqlTypeValue`
  Parameters:
    `ps` - the PreparedStatement to work on
    `paramIndex` - the index of the parameter for which we need to set the value
    `sqlType` - SQL type of the parameter we are setting
    `typeName` - the type name of the parameter (optional)
  Throws:
    `java.sql.SQLException` - if a SQLException is encountered while setting parameter values
  See Also:
    `Types`, `PreparedStatement.setObject(int, java.lang.Object, int)`

### createTypeValue

    protected abstract java.lang.Object createTypeValue(java.sql.Connection con,
                                                        int sqlType,
                                                        java.lang.String typeName)
                                                 throws java.sql.SQLException

  Create the type value to be passed into `PreparedStatement.setObject`.

  Parameters:
    `con` - the JDBC Connection, if needed to create any database-specific objects
    `sqlType` - SQL type of the parameter we are setting
    `typeName` - the type name of the parameter
  Returns:
    the type value
  Throws:
    `java.sql.SQLException` - if a SQLException is encountered setting parameter values (that is, there's no need to catch SQLException)
  See Also:
    `PreparedStatement.setObject(int, Object, int)`

Overview | Package | Class | Tree | Deprecated | Index | Help
| Spring Framework
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD