HikariCP version: 2.7.9 (tried with the latest as well)
JDK version : 1.8.0_101
Database : Oracle
Driver version : 12.1.0.2.0
EclipseLink version: 2.7
SpringBoot version: 2.0.2.RELEASE
Hi,
I am trying to configure a SpringBoot project to use Eclipselink instead of Hibernate and I would like to take advantage of HikariCP since it's now default pool in the spring boot stack. The problem arises when the native connection needs to be fetched in order to perform mapping of some Oracle specific type (TIMESTAMPTZ in an example I tested). Since HikariCP wraps connection into HikariProxyConnection, ojdbc7 fails to cast it as an OracleConnection.
Has anyone had any experience with this type of setup? Is there a way to configure HikariCP to return platform specific connection types?
Thanks
The official way is to call Connection.unwrap(...).
For Spring Boot. Get an OracleDataSource
import java.sql.SQLException;
import javax.sql.DataSource;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import oracle.jdbc.pool.OracleDataSource;
@Configuration
public class DataSourceConfig
{
@Value("${spring.datasource.username}")
private String username;
@Value("${spring.datasource.password}")
private String password;
@Value("${spring.datasource.url}")
private String url;
@Bean
public DataSource dataSource() throws SQLException
{
OracleDataSource dataSource = new OracleDataSource();
dataSource.setUser(username);
dataSource.setPassword(password);
dataSource.setURL(url);
dataSource.setImplicitCachingEnabled(true);
dataSource.setFastConnectionFailoverEnabled(true);
return dataSource;
}
}
Most helpful comment
The official way is to call
Connection.unwrap(...).