Cannot open Oracle connection

3,625 views
Skip to first unread message

José Ignacio Santa Cruz

unread,
Jul 4, 2014, 10:08:06 AM7/4/14
to hika...@googlegroups.com
Hi!
I'm trying to make a comparison between different connection pools, the idea is using a simple one line change setting to use different pools. 
Already tried with BoneCP, DBCP, C3PO and all work fine, but when trying Hikari I get a:

jul 03, 2014 9:45:33 PM org.hibernate.engine.jdbc.spi.SqlExceptionHelper logExceptions
ERROR: Timeout of 300000ms encountered waiting for connection.
[...]
org.hibernate.exception.GenericJDBCException: Could not open connection

This are the settings I'm using:

<Resource name="jdbc/OracleHikari" auth="Container"
factory="com.zaxxer.hikari.HikariJNDIFactory" type="javax.sql.DataSource"
driverClassName="oracle.jdbc.driver.OracleDriver" dataSourceClassName="oracle.jdbc.pool.OracleDataSource"
minimumIdle="5" maximumPoolSize="10" connectionTimeout="300000"
implicitCachingEnabled="true" jdbcUrl="jdbc:oracle:thin:@orcl_server:1521:orcl"
user="user" password="pwd" />

My database is an Oracle, operating in the same network. the server is a Tomcat 7. 

Similar settings with the other pools I mentioned actually work, but Hikari is the only one that can't open connection.
Any hints?

Best regards from Chile.
José Ignacio

Brett Wooldridge

unread,
Jul 4, 2014, 11:18:05 AM7/4/14
to hika...@googlegroups.com
I would suggest enabling DEBUG logging and initializationFailFast=true to get the root exception of why connections cannot be created.  Looking at the code, it also seems like implicitCachingEnabled=true will not be passed through (but will not cause a failure).  This parameter can be added to the jdbcUrl.  Also, either driverClassName or dataSourceClassName should be used, but not both -- but if you're using the jdbcUrl then it must be driverClassName.

Post back when you get logs.

José Ignacio Santa Cruz

unread,
Jul 4, 2014, 5:23:55 PM7/4/14
to hika...@googlegroups.com
Thanks for the hint, still nothing clear for me... :(
Here's the log:
Información: Starting Servlet Engine: Apache Tomcat/7.0.47
[localhost-startStop-1] INFO com.zaxxer.hikari.HikariDataSource - HikariCP pool HikariPool-0 is starting.
jul 04, 2014 5:20:56 PM org.apache.naming.NamingContext lookup
Advertencia: Unexpected exception resolving reference
java.lang.RuntimeException: Fail-fast during pool initialization
    at com.zaxxer.hikari.pool.HikariPool.fillPool(HikariPool.java:446)
    at com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:142)
    at com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:99)
    at com.zaxxer.hikari.HikariDataSource.<init>(HikariDataSource.java:78)
    at com.zaxxer.hikari.HikariJNDIFactory.createDataSource(HikariJNDIFactory.java:71)
    at com.zaxxer.hikari.HikariJNDIFactory.getObjectInstance(HikariJNDIFactory.java:62)
    at org.apache.naming.factory.ResourceFactory.getObjectInstance(ResourceFactory.java:143)
    at javax.naming.spi.NamingManager.getObjectInstance(Unknown Source)
    at org.apache.naming.NamingContext.lookup(NamingContext.java:843)
    at org.apache.naming.NamingContext.lookup(NamingContext.java:154)
    at org.apache.naming.NamingContext.lookup(NamingContext.java:831)
    at org.apache.naming.NamingContext.lookup(NamingContext.java:168)
    at org.apache.catalina.core.NamingContextListener.addResource(NamingContextListener.java:1093)
    at org.apache.catalina.core.NamingContextListener.createNamingContext(NamingContextListener.java:672)
    at org.apache.catalina.core.NamingContextListener.lifecycleEvent(NamingContextListener.java:271)
    at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
    at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5322)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
Caused by: java.sql.SQLException: argumentos no válidos en la llamada
    at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
    at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:146)
    at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:208)
    at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:236)
    at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:414)
    at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:165)
    at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:35)
    at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:801)
    at java.sql.DriverManager.getConnection(Unknown Source)
    at java.sql.DriverManager.getConnection(Unknown Source)
    at com.zaxxer.hikari.util.DriverDataSource.getConnection(DriverDataSource.java:58)
    at com.zaxxer.hikari.util.DriverDataSource.getConnection(DriverDataSource.java:64)
    at com.zaxxer.hikari.pool.HikariPool.addConnection(HikariPool.java:378)
    at com.zaxxer.hikari.pool.HikariPool.fillPool(HikariPool.java:445)
    ... 24 more

Tried cleaning up the datasource params. Still get the same errors.

Brett Wooldridge

unread,
Jul 5, 2014, 2:49:18 AM7/5/14
to hika...@googlegroups.com
Try this (uses Driver):

<Resource name="jdbc/OracleHikari" auth="Container"
  factory="com.zaxxer.hikari.HikariJNDIFactory"
      type="javax.sql.DataSource"
  minimumIdle="5" 
      maximumPoolSize="10"
      connectionTimeout="300000"
  driverClassName="oracle.jdbc.driver.OracleDriver"
      jdbcUrl="jdbc:oracle:thin:@orcl_server:1521:orcl"
dataSource.implicitCachingEnabled="true" 
  dataSource.user="user"
      dataSource.password="pwd" />

or this (uses DataSource):

<Resource name="jdbc/OracleHikari" auth="Container"
  factory="com.zaxxer.hikari.HikariJNDIFactory"
      type="javax.sql.DataSource"
  minimumIdle="5" 
      maximumPoolSize="10"
      connectionTimeout="300000"
  dataSourceClassName="oracle.jdbc.pool.OracleDataSource"
dataSource.implicitCachingEnabled="true" 
  dataSource.user="user"
      dataSource.password="pwd"
      dataSource.url="jdbc:oracle:thin:@orcl_server:1521:orcl"/>

José Ignacio Santa Cruz

unread,
Jul 7, 2014, 5:45:20 PM7/7/14
to hika...@googlegroups.com
Added initializationFailFast="true" to both configurations.
By the way, I'm using ojdbc4.jar driver for Oracle 11G.

Using Driver (invalid arguments in call):

[localhost-startStop-1] INFO com.zaxxer.hikari.HikariDataSource - HikariCP pool HikariPool-0 is starting.
jul 07, 2014 5:37:30 PM org.apache.naming.NamingContext lookup
    at com.zaxxer.hikari.pool.HikariPool.addConnection(HikariPool.java:378)
    at com.zaxxer.hikari.pool.HikariPool.fillPool(HikariPool.java:445)
    ... 24 more


Using DataSource (invalid Oracle URL):

[localhost-startStop-1] INFO com.zaxxer.hikari.HikariDataSource - HikariCP pool HikariPool-0 is starting.
jul 07, 2014 5:30:56 PM org.apache.naming.NamingContext lookup
Caused by: java.sql.SQLException: La dirección URL de Oracle especificada no es válida: OracleDataSource.makeURL

    at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
    at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:146)
    at oracle.jdbc.pool.OracleDataSource.makeURL(OracleDataSource.java:1353)
    at oracle.jdbc.pool.OracleDataSource.getConnection(OracleDataSource.java:195)
    at oracle.jdbc.pool.OracleDataSource.getConnection(OracleDataSource.java:165)

    at com.zaxxer.hikari.pool.HikariPool.addConnection(HikariPool.java:378)
    at com.zaxxer.hikari.pool.HikariPool.fillPool(HikariPool.java:445)
    ... 24 more



Brett Wooldridge

unread,
Jul 7, 2014, 11:12:03 PM7/7/14
to hika...@googlegroups.com
José,

I finally tracked it down.  There was a bug in HikariJndiFactory that would not pass dataSource.* properties through to the pool.  I have checked in a fix for this, it will be included in the next release of HikariCP.  For now, you can clone and build HikariCP yourself.

git clone https://github.com/brettwooldridge/HikariCP.git
cd HikariCP
(If you have Java 6/7 and not Java 8, then also: cd hikariCP-java6)
mvn install

You can then use version dependency "HikariCP-java6" and version "2.0.0-SNAPSHOT" if you are using maven, or if not just copy the HikariCP-java6-2.0.0-SNAPSHOT.jar from the target directory.

You can use either of the configurations above (driver or DataSource).

José Ignacio Santa Cruz

unread,
Jul 17, 2014, 10:24:05 AM7/17/14
to hika...@googlegroups.com
Thanks I'll check it out and share my findings.
Best regards.

José Ignacio Santa Cruz

unread,
Jul 17, 2014, 10:59:53 AM7/17/14
to hika...@googlegroups.com
OK, my findings.
Works without problems using both dataSourceClassName and driverClassName.
Just be careful to use the ojdbc6 Oracle driver, tried with the ojdc14 and got exception: AbstractMethodError: oracle.jdbc.driver.T4CConnection.isValid (I) Z

Brett Wooldridge

unread,
Jul 17, 2014, 11:05:02 AM7/17/14
to hika...@googlegroups.com
For the ojdbc14 driver you would need to turn off the jdbc4ConnectionTest and instead use the connectionTestQuery.


Reply all
Reply to author
Forward
0 new messages