Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HikariConfig pool for Oracle

I want to configure HikariConfig pool for Oracle:

Properties props = new Properties();
        props.setProperty("dataSourceClassName",     "oracle.jdbc.driver.OracleDriver");
        props.setProperty("dataSource.user",         bundle.getString("db.user"));
        props.setProperty("dataSource.password",     bundle.getString("db.password"));
        props.setProperty("dataSource.databaseName", "xe");

        config = new HikariConfig(props);
        ds = new HikariDataSource(config);

But I got this error

Exception in thread "main" java.lang.RuntimeException: java.lang.ClassCastException: Cannot cast oracle.jdbc.driver.OracleDriver to javax.sql.DataSource
    at com.zaxxer.hikari.util.UtilityElf.createInstance(UtilityElf.java:93)
    at com.zaxxer.hikari.pool.PoolBase.initializeDataSource(PoolBase.java:339)
    at com.zaxxer.hikari.pool.PoolBase.<init>(PoolBase.java:118)
    at com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:106)
    at com.zaxxer.hikari.HikariDataSource.<init>(HikariDataSource.java:72)
    at 
like image 263
Nunyet de Can Calçada Avatar asked Sep 08 '17 12:09

Nunyet de Can Calçada


People also ask

What is HikariConfig?

HikariConfig is the configuration class used to initialize a data source. It comes with four well-known, must-use parameters: username, password, jdbcUrl, and dataSourceClassName. Out of jdbcUrl and dataSourceClassName, we generally use one at a time.

What is Hikari maximum pool size?

The maximumPoolSize sets the maximum size of connections in HikariCP, in this example the connection limit will be 25. The minimumIdle sets the minimum number of pending connections in the queue to be used. The idleTimeout is the time the connection can be queued.

What is Oracle connection pool?

The connection pool is an object in the Physical layer that describes access to the data source. It contains information about the connection between the Oracle BI Server and that data source.

What is Hikari pool name?

"HikariCP is solid high-performance JDBC connection pool. A connection pool is a cache of database connections maintained so that the connections can be reused when future requests to the database are required.


1 Answers

you are trying to set driver to datasouce class.

This is how I do,

        HikariConfig config = new HikariConfig();
        config.setMaximumPoolSize(10);
        config.setMinimumIdle(5);
        config.setDriverClassName("org.hsqldb.jdbc.JDBCDriver");
        config.setJdbcUrl("jdbc:hsqldb:hsql://localhost/");
        config.addDataSourceProperty("user", "SA");
        config.addDataSourceProperty("password", "");

        HikariDataSource ds = new HikariDataSource(config);
        System.out.print("Data source created");
        Connection conn = ds.getConnection();
like image 171
Bala Avatar answered Sep 23 '22 07:09

Bala