org.springframework.jdbc.support.nativejdbc
Class Jdbc4NativeJdbcExtractor

java.lang.Object
  extended by org.springframework.jdbc.support.nativejdbc.NativeJdbcExtractorAdapter
      extended by org.springframework.jdbc.support.nativejdbc.Jdbc4NativeJdbcExtractor
All Implemented Interfaces:
NativeJdbcExtractor
Direct Known Subclasses:
OracleJdbc4NativeJdbcExtractor

public class Jdbc4NativeJdbcExtractor
extends NativeJdbcExtractorAdapter

NativeJdbcExtractor implementation that delegates to JDBC 4.0's unwrap method, as defined by Wrapper. You will typically need to specify a vendor Connection type / Statement type / ResultSet type to extract, since JDBC 4.0 only actually unwraps to a given target type.

Note: Only use this when actually running against a JDBC 4.0 driver, with a connection pool that supports the JDBC 4.0 API (i.e. at least accepts JDBC 4.0 API calls and passes them through to the underlying driver)! Other than that, there is no need for connection pool specific setup. As of JDBC 4.0, NativeJdbcExtractors will typically be implemented for specific drivers instead of for specific pools (e.g. OracleJdbc4NativeJdbcExtractor).

Since:
2.5
Author:
Juergen Hoeller
See Also:
Wrapper.unwrap(java.lang.Class), SimpleNativeJdbcExtractor, JdbcTemplate.setNativeJdbcExtractor(org.springframework.jdbc.support.nativejdbc.NativeJdbcExtractor), OracleLobHandler.setNativeJdbcExtractor(org.springframework.jdbc.support.nativejdbc.NativeJdbcExtractor)

Field Summary
private  java.lang.Class<? extends java.sql.CallableStatement> callableStatementType
           
private  java.lang.Class<? extends java.sql.Connection> connectionType
           
private  java.lang.Class<? extends java.sql.PreparedStatement> preparedStatementType
           
private  java.lang.Class<? extends java.sql.ResultSet> resultSetType
           
private  java.lang.Class<? extends java.sql.Statement> statementType
           
 
Constructor Summary
Jdbc4NativeJdbcExtractor()
           
 
Method Summary
protected  java.sql.Connection doGetNativeConnection(java.sql.Connection con)
          Not able to unwrap: return passed-in Connection.
 java.sql.CallableStatement getNativeCallableStatement(java.sql.CallableStatement cs)
          Not able to unwrap: return passed-in CallableStatement.
 java.sql.PreparedStatement getNativePreparedStatement(java.sql.PreparedStatement ps)
          Not able to unwrap: return passed-in PreparedStatement.
 java.sql.ResultSet getNativeResultSet(java.sql.ResultSet rs)
          Not able to unwrap: return passed-in ResultSet.
 java.sql.Statement getNativeStatement(java.sql.Statement stmt)
          Not able to unwrap: return passed-in Statement.
 void setCallableStatementType(java.lang.Class<? extends java.sql.CallableStatement> callableStatementType)
          Set the vendor's CallableStatement type, e.g.
 void setConnectionType(java.lang.Class<? extends java.sql.Connection> connectionType)
          Set the vendor's Connection type, e.g.
 void setPreparedStatementType(java.lang.Class<? extends java.sql.PreparedStatement> preparedStatementType)
          Set the vendor's PreparedStatement type, e.g.
 void setResultSetType(java.lang.Class<? extends java.sql.ResultSet> resultSetType)
          Set the vendor's ResultSet type, e.g.
 void setStatementType(java.lang.Class<? extends java.sql.Statement> statementType)
          Set the vendor's Statement type, e.g.
 
Methods inherited from class org.springframework.jdbc.support.nativejdbc.NativeJdbcExtractorAdapter
getNativeConnection, getNativeConnectionFromStatement, isNativeConnectionNecessaryForNativeCallableStatements, isNativeConnectionNecessaryForNativePreparedStatements, isNativeConnectionNecessaryForNativeStatements
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

connectionType

private java.lang.Class<? extends java.sql.Connection> connectionType

statementType

private java.lang.Class<? extends java.sql.Statement> statementType

preparedStatementType

private java.lang.Class<? extends java.sql.PreparedStatement> preparedStatementType

callableStatementType

private java.lang.Class<? extends java.sql.CallableStatement> callableStatementType

resultSetType

private java.lang.Class<? extends java.sql.ResultSet> resultSetType
Constructor Detail

Jdbc4NativeJdbcExtractor

public Jdbc4NativeJdbcExtractor()
Method Detail

setConnectionType

public void setConnectionType(java.lang.Class<? extends java.sql.Connection> connectionType)
Set the vendor's Connection type, e.g. oracle.jdbc.OracleConnection.


setStatementType

public void setStatementType(java.lang.Class<? extends java.sql.Statement> statementType)
Set the vendor's Statement type, e.g. oracle.jdbc.OracleStatement.


setPreparedStatementType

public void setPreparedStatementType(java.lang.Class<? extends java.sql.PreparedStatement> preparedStatementType)
Set the vendor's PreparedStatement type, e.g. oracle.jdbc.OraclePreparedStatement.


setCallableStatementType

public void setCallableStatementType(java.lang.Class<? extends java.sql.CallableStatement> callableStatementType)
Set the vendor's CallableStatement type, e.g. oracle.jdbc.OracleCallableStatement.


setResultSetType

public void setResultSetType(java.lang.Class<? extends java.sql.ResultSet> resultSetType)
Set the vendor's ResultSet type, e.g. oracle.jdbc.OracleResultSet.


doGetNativeConnection

protected java.sql.Connection doGetNativeConnection(java.sql.Connection con)
                                             throws java.sql.SQLException
Description copied from class: NativeJdbcExtractorAdapter
Not able to unwrap: return passed-in Connection.

Overrides:
doGetNativeConnection in class NativeJdbcExtractorAdapter
Throws:
java.sql.SQLException

getNativeStatement

public java.sql.Statement getNativeStatement(java.sql.Statement stmt)
                                      throws java.sql.SQLException
Description copied from class: NativeJdbcExtractorAdapter
Not able to unwrap: return passed-in Statement.

Specified by:
getNativeStatement in interface NativeJdbcExtractor
Overrides:
getNativeStatement in class NativeJdbcExtractorAdapter
Parameters:
stmt - the Statement handle, potentially wrapped by a connection pool
Returns:
the underlying native JDBC Statement, if possible; else, the original Statement
Throws:
java.sql.SQLException - if thrown by JDBC methods

getNativePreparedStatement

public java.sql.PreparedStatement getNativePreparedStatement(java.sql.PreparedStatement ps)
                                                      throws java.sql.SQLException
Description copied from class: NativeJdbcExtractorAdapter
Not able to unwrap: return passed-in PreparedStatement.

Specified by:
getNativePreparedStatement in interface NativeJdbcExtractor
Overrides:
getNativePreparedStatement in class NativeJdbcExtractorAdapter
Parameters:
ps - the PreparedStatement handle, potentially wrapped by a connection pool
Returns:
the underlying native JDBC PreparedStatement, if possible; else, the original PreparedStatement
Throws:
java.sql.SQLException - if thrown by JDBC methods

getNativeCallableStatement

public java.sql.CallableStatement getNativeCallableStatement(java.sql.CallableStatement cs)
                                                      throws java.sql.SQLException
Description copied from class: NativeJdbcExtractorAdapter
Not able to unwrap: return passed-in CallableStatement.

Specified by:
getNativeCallableStatement in interface NativeJdbcExtractor
Overrides:
getNativeCallableStatement in class NativeJdbcExtractorAdapter
Parameters:
cs - the CallableStatement handle, potentially wrapped by a connection pool
Returns:
the underlying native JDBC CallableStatement, if possible; else, the original CallableStatement
Throws:
java.sql.SQLException - if thrown by JDBC methods

getNativeResultSet

public java.sql.ResultSet getNativeResultSet(java.sql.ResultSet rs)
                                      throws java.sql.SQLException
Description copied from class: NativeJdbcExtractorAdapter
Not able to unwrap: return passed-in ResultSet.

Specified by:
getNativeResultSet in interface NativeJdbcExtractor
Overrides:
getNativeResultSet in class NativeJdbcExtractorAdapter
Parameters:
rs - the ResultSet handle, potentially wrapped by a connection pool
Returns:
the underlying native JDBC ResultSet, if possible; else, the original ResultSet
Throws:
java.sql.SQLException - if thrown by JDBC methods