1 16 17 package org.springframework.jdbc.support.nativejdbc; 18 19 import java.lang.reflect.Method ; 20 import java.sql.Connection ; 21 import java.sql.SQLException ; 22 23 import org.springframework.util.ReflectionUtils; 24 25 44 public class WebLogicNativeJdbcExtractor extends NativeJdbcExtractorAdapter { 45 46 private static final String JDBC_EXTENSION_NAME = "weblogic.jdbc.extensions.WLConnection"; 47 48 49 private final Class jdbcExtensionClass; 50 51 private final Method getVendorConnectionMethod; 52 53 54 58 public WebLogicNativeJdbcExtractor() { 59 try { 60 this.jdbcExtensionClass = getClass().getClassLoader().loadClass(JDBC_EXTENSION_NAME); 61 this.getVendorConnectionMethod = this.jdbcExtensionClass.getMethod("getVendorConnection", (Class []) null); 62 } 63 catch (Exception ex) { 64 throw new IllegalStateException ( 65 "Could not initialize WebLogicNativeJdbcExtractor because WebLogic API classes are not available: " + ex); 66 } 67 } 68 69 70 73 public boolean isNativeConnectionNecessaryForNativeStatements() { 74 return true; 75 } 76 77 80 public boolean isNativeConnectionNecessaryForNativePreparedStatements() { 81 return true; 82 } 83 84 87 public boolean isNativeConnectionNecessaryForNativeCallableStatements() { 88 return true; 89 } 90 91 94 protected Connection doGetNativeConnection(Connection con) throws SQLException { 95 if (this.jdbcExtensionClass.isAssignableFrom(con.getClass())) { 96 return (Connection ) ReflectionUtils.invokeMethod(this.getVendorConnectionMethod, con); 97 } 98 return con; 99 } 100 101 } 102 | Popular Tags |