Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hikaricp Oracle connection issue

I have the following code to get connection to the oracle database. But using hikaricp I am getting the exception.

java.sql.SQLException: Invalid Oracle URL specified: OracleDataSource.makeURL

Code:

private static HikariDataSource dataSource() {
    final HikariDataSource hikariDataSource = new HikariDataSource();
    hikariDataSource.setMaximumPoolSize(100);
    hikariDataSource.setMinimumIdle(10);
    hikariDataSource.setDataSourceClassName("oracle.jdbc.pool.OracleDataSource");

    Properties properties = new Properties();
    properties.put("user", "user");
    properties.put("password", "pass");
    properties.put("databaseName", "XE");
    properties.put("serverName", "192.168.21.13");
    properties.put("portNumber", "1521");
    hikariDataSource.setDataSourceProperties(properties);
    //Additionally I am setting connection test query and max life time also
    return hikariDataSource;
}

The complete stacktrace is

Exception in thread "main" java.lang.RuntimeException: Fail-fast during pool initialization
    at com.zaxxer.hikari.pool.HikariPool.fillPool(HikariPool.java:499)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:162)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:113)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:102)
    at java.lang.reflect.Method.invoke(Method.java:597)
Caused by: java.sql.SQLException: Invalid Oracle URL specified: OracleDataSource.makeURL
    at oracle.jdbc.pool.OracleDataSource.makeURL(OracleDataSource.java:1277)
    at oracle.jdbc.pool.OracleDataSource.getConnection(OracleDataSource.java:185)
    at oracle.jdbc.pool.OracleDataSource.getConnection(OracleDataSource.java:157)
    at com.zaxxer.hikari.pool.HikariPool.addConnection(HikariPool.java:418)
    at com.zaxxer.hikari.pool.HikariPool.fillPool(HikariPool.java:498)
    ... 11 more

How do I establish successful pool? I am using oracle jar http://download.oracle.com/otn/utilities_drivers/jdbc/111070/ojdbc6.jar and the jdk is 1.6. Hikaricp version is 2.2.5 for java 6.

like image 526
phoenix Avatar asked Feb 11 '23 09:02

phoenix


1 Answers

try to set the driver type to thin.

properties.put("driverType", "thin");
like image 70
valentin Avatar answered Feb 24 '23 14:02

valentin