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

## org.springframework.jdbc.support.nativejdbc
Class SimpleNativeJdbcExtractor

    java.lang.Object
      org.springframework.jdbc.support.nativejdbc.NativeJdbcExtractorAdapter
          org.springframework.jdbc.support.nativejdbc.SimpleNativeJdbcExtractor

All Implemented Interfaces:
  NativeJdbcExtractor

    public class SimpleNativeJdbcExtractor

extends NativeJdbcExtractorAdapter

Simple implementation of the NativeJdbcExtractor interface. Assumes a pool that wraps Connection handles but not DatabaseMetaData: In this case, the underlying native Connection can be retrieved by simply calling `conHandle.getMetaData().getConnection()`. All other JDBC objects will be returned as passed in.

This extractor should work with any pool that does not wrap DatabaseMetaData, and will also work with any plain JDBC driver. Note that a pool can still wrap Statements, PreparedStatements, etc: The only requirement of this extractor is that `java.sql.DatabaseMetaData` does not get wrapped, returning the native Connection of the JDBC driver on `metaData.getConnection()`.

Customize this extractor by setting the "nativeConnectionNecessaryForXxx" flags accordingly: If Statements, PreparedStatements, and/or CallableStatements are wrapped by your pool, set the corresponding "nativeConnectionNecessaryForXxx" flags to "true". If none of the statement types is wrapped - or you solely need Connection unwrapping in the first place -, the defaults are fine.

SimpleNativeJdbcExtractor is a common choice for use with OracleLobHandler, which just needs Connection unwrapping via the `getNativeConnectionFromStatement` method. This usage will work with almost any connection pool. Known to work are, for example:

- Caucho Resin 2.1.x, 3.0.x
- Sun Java System Application Server 8
- Oracle OC4J 9.0.3, 9.0.4
- C3P0 0.8.x
- Jakarta Commons DBCP 1.0, 1.1, 1.2 (used in Tomcat 4.1.x, 5.0.x)
- JBoss 3.2.x

For full usage with JdbcTemplate, i.e. to also provide Statement unwrapping:

- Use a default SimpleNativeJdbcExtractor for Resin and SJSAS (no JDBC Statement objects are wrapped, therefore no special unwrapping is necessary).
- Use a SimpleNativeJdbcExtractor with all "nativeConnectionNecessaryForXxx" flags set to "true" for OC4J and C3P0 (all JDBC Statement objects are wrapped, but none of the wrappers allow for unwrapping).
- Use a CommonsDbcpNativeJdbcExtractor for Jakarta Commons DBCP respectively a JBossNativeJdbcExtractor for JBoss (all JDBC Statement objects are wrapped, but all of them can be extracted by casting to implementation classes).

Since:
  05.12.2003
Author:
  Juergen Hoeller
See Also:
  `DatabaseMetaData.getConnection()`, `NativeJdbcExtractorAdapter.getNativeConnection(java.sql.Connection)`, `setNativeConnectionNecessaryForNativeStatements(boolean)`, `setNativeConnectionNecessaryForNativePreparedStatements(boolean)`, `setNativeConnectionNecessaryForNativeCallableStatements(boolean)`, `CommonsDbcpNativeJdbcExtractor`, `JBossNativeJdbcExtractor`, `JdbcTemplate.setNativeJdbcExtractor(org.springframework.jdbc.support.nativejdbc.NativeJdbcExtractor)`, `OracleLobHandler.setNativeJdbcExtractor(org.springframework.jdbc.support.nativejdbc.NativeJdbcExtractor)`

Constructor Summary
`SimpleNativeJdbcExtractor()`

Method Summary
`boolean` | `isNativeConnectionNecessaryForNativeCallableStatements()` Return `false` by default.
`boolean` | `isNativeConnectionNecessaryForNativePreparedStatements()` Return `false` by default.
`boolean` | `isNativeConnectionNecessaryForNativeStatements()` Return `false` by default.
`void` | `setNativeConnectionNecessaryForNativeCallableStatements(boolean nativeConnectionNecessary)` Set whether it is necessary to work on the native Connection to receive native CallableStatements.
`void` | `setNativeConnectionNecessaryForNativePreparedStatements(boolean nativeConnectionNecessary)` Set whether it is necessary to work on the native Connection to receive native PreparedStatements.
`void` | `setNativeConnectionNecessaryForNativeStatements(boolean nativeConnectionNecessaryForNativeStatements)` Set whether it is necessary to work on the native Connection to receive native Statements.

Methods inherited from class org.springframework.jdbc.support.nativejdbc.NativeJdbcExtractorAdapter
`doGetNativeConnection, getNativeCallableStatement, getNativeConnection, getNativeConnectionFromStatement, getNativePreparedStatement, getNativeResultSet, getNativeStatement`

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

Constructor Detail

### SimpleNativeJdbcExtractor

    public SimpleNativeJdbcExtractor()

Method Detail

### setNativeConnectionNecessaryForNativeStatements

    public void setNativeConnectionNecessaryForNativeStatements(boolean nativeConnectionNecessaryForNativeStatements)

  Set whether it is necessary to work on the native Connection to receive native Statements. Default is "false". If true, the Connection will be unwrapped first to create a Statement.

  This makes sense if you need to work with native Statements from a pool that does not allow to extract the native JDBC objects from its wrappers but returns the native Connection on DatabaseMetaData.getConnection.

  The standard SimpleNativeJdbcExtractor is unable to unwrap statements, so set this to true if your connection pool wraps Statements.

  See Also:
    `Connection.createStatement()`, `DatabaseMetaData.getConnection()`

### isNativeConnectionNecessaryForNativeStatements

    public boolean isNativeConnectionNecessaryForNativeStatements()

  Description copied from class: `NativeJdbcExtractorAdapter`
  Return `false` by default.

  Specified by:
    `isNativeConnectionNecessaryForNativeStatements` in interface `NativeJdbcExtractor`
  Overrides:
    `isNativeConnectionNecessaryForNativeStatements` in class `NativeJdbcExtractorAdapter`

### setNativeConnectionNecessaryForNativePreparedStatements

    public void setNativeConnectionNecessaryForNativePreparedStatements(boolean nativeConnectionNecessary)

  Set whether it is necessary to work on the native Connection to receive native PreparedStatements. Default is "false". If true, the Connection will be unwrapped first to create a PreparedStatement.

  This makes sense if you need to work with native PreparedStatements from a pool that does not allow to extract the native JDBC objects from its wrappers but returns the native Connection on Statement.getConnection.

  The standard SimpleNativeJdbcExtractor is unable to unwrap statements, so set this to true if your connection pool wraps PreparedStatements.

  See Also:
    `Connection.prepareStatement(java.lang.String)`, `DatabaseMetaData.getConnection()`

### isNativeConnectionNecessaryForNativePreparedStatements

    public boolean isNativeConnectionNecessaryForNativePreparedStatements()

  Description copied from class: `NativeJdbcExtractorAdapter`
  Return `false` by default.

  Specified by:
    `isNativeConnectionNecessaryForNativePreparedStatements` in interface `NativeJdbcExtractor`
  Overrides:
    `isNativeConnectionNecessaryForNativePreparedStatements` in class `NativeJdbcExtractorAdapter`

### setNativeConnectionNecessaryForNativeCallableStatements

    public void setNativeConnectionNecessaryForNativeCallableStatements(boolean nativeConnectionNecessary)

  Set whether it is necessary to work on the native Connection to receive native CallableStatements. Default is "false". If true, the Connection will be unwrapped first to create a CallableStatement.

  This makes sense if you need to work with native CallableStatements from a pool that does not allow to extract the native JDBC objects from its wrappers but returns the native Connection on Statement.getConnection.

  The standard SimpleNativeJdbcExtractor is unable to unwrap statements, so set this to true if your connection pool wraps CallableStatements.

  See Also:
    `Connection.prepareCall(java.lang.String)`, `DatabaseMetaData.getConnection()`

### isNativeConnectionNecessaryForNativeCallableStatements

    public boolean isNativeConnectionNecessaryForNativeCallableStatements()

  Description copied from class: `NativeJdbcExtractorAdapter`
  Return `false` by default.

  Specified by:
    `isNativeConnectionNecessaryForNativeCallableStatements` in interface `NativeJdbcExtractor`
  Overrides:
    `isNativeConnectionNecessaryForNativeCallableStatements` in class `NativeJdbcExtractorAdapter`

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

Copyright © 2002-2007 The Spring Framework.