Created
May 15, 2020 19:35
-
-
Save jccartwright/b65c231b1a499f90235ee27a1581ff5e to your computer and use it in GitHub Desktop.
get a native OracleConnection from the SpringBoot-provided DataSource
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
assert dataSource != null | |
assert dataSource.getClass().name == 'org.apache.tomcat.jdbc.pool.DataSource' | |
assert dataSource.getConnection().getClass().name.startsWith('com.sun.proxy') | |
OracleConnection oracleConnection = dataSource.getConnection().unwrap(OracleConnection) | |
assert oracleConnection.getClass().name == 'oracle.jdbc.driver.T4CConnection' | |
NativeJdbcExtractor jdbcExtractor = new CommonsDbcpNativeJdbcExtractor() | |
OracleConnection con = jdbcExtractor.getNativeConnection(dataSource.getConnection()) | |
assert con.getClass().name == 'oracle.jdbc.driver.T4CConnection' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment