001/* 002 * Copyright 2002-2012 the original author or authors. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * https://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 017package org.springframework.jdbc.support.nativejdbc; 018 019import java.sql.CallableStatement; 020import java.sql.Connection; 021import java.sql.PreparedStatement; 022import java.sql.ResultSet; 023import java.sql.Statement; 024 025/** 026 * A {@link Jdbc4NativeJdbcExtractor} which comes pre-configured for Oracle's JDBC driver, 027 * specifying the following vendor-specific API types for unwrapping: 028 * <ul> 029 * <li>{@code oracle.jdbc.OracleConnection} 030 * <li>{@code oracle.jdbc.OracleStatement} 031 * <li>{@code oracle.jdbc.OraclePreparedStatement} 032 * <li>{@code oracle.jdbc.OracleCallableStatement} 033 * <li>{@code oracle.jdbc.OracleResultSet} 034 * </ul> 035 * 036 * <p>Note: This will work with any JDBC 4.0 compliant connection pool, without a need for 037 * connection pool specific setup. In other words, as of JDBC 4.0, NativeJdbcExtractors 038 * will typically be implemented for specific drivers instead of for specific pools. 039 * 040 * @author Juergen Hoeller 041 * @since 3.0.5 042 */ 043public class OracleJdbc4NativeJdbcExtractor extends Jdbc4NativeJdbcExtractor { 044 045 @SuppressWarnings("unchecked") 046 public OracleJdbc4NativeJdbcExtractor() { 047 try { 048 setConnectionType((Class<Connection>) getClass().getClassLoader().loadClass("oracle.jdbc.OracleConnection")); 049 setStatementType((Class<Statement>) getClass().getClassLoader().loadClass("oracle.jdbc.OracleStatement")); 050 setPreparedStatementType((Class<PreparedStatement>) getClass().getClassLoader().loadClass("oracle.jdbc.OraclePreparedStatement")); 051 setCallableStatementType((Class<CallableStatement>) getClass().getClassLoader().loadClass("oracle.jdbc.OracleCallableStatement")); 052 setResultSetType((Class<ResultSet>) getClass().getClassLoader().loadClass("oracle.jdbc.OracleResultSet")); 053 } 054 catch (Exception ex) { 055 throw new IllegalStateException( 056 "Could not initialize OracleJdbc4NativeJdbcExtractor because Oracle API classes are not available: " + ex); 057 } 058 } 059 060}