Unable to get db connection after Java 8 upgrade
Asked Answered
F

1

11

I have recently upgraded an application from java 1.7 to 1.8. Rest of the libraries versions remains unchanged. I am getting the following error after the upgrade:

DEBUG 2015-11-12 09:55:12 BasicResourcePool         An exception occurred while acquiring a poolable resource. Will retry.
java.lang.NullPointerException
    at oracle.net.jndi.JndiAttrs.getAttrs(JndiAttrs.java:207)
    at oracle.net.resolver.AddrResolution.<init>(AddrResolution.java:198)
    at oracle.net.ns.NSProtocol.connect(NSProtocol.java:219)
    at oracle.jdbc.driver.T4CConnection.connect(T4CConnection.java:1102)
    at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:320)
    at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:546)
    at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:236)
    at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:32)
    at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:521)
    at com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:134)
    at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:182)
    at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:171)
    at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.acquireResource(C3P0PooledConnectionPool.java:137)
    at com.mchange.v2.resourcepool.BasicResourcePool.doAcquire(BasicResourcePool.java:1014)
    at com.mchange.v2.resourcepool.BasicResourcePool.access$800(BasicResourcePool.java:32)
    at com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask.run(BasicResourcePool.java:1810)
    at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:547)

Hibernate configurations:

<hibernate-configuration>
    <session-factory>
        <property name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
        <property name="hibernate.connection.url">jdbc:oracle:thin:@ldaps://XXXX,cn=OOOO,dc=WWW</property>
        <property name="hibernate.connection.username">YYYY</property>
        <property name="hibernate.statement_cache.size">0</property>
        <property name="hibernate.connection.password">ZZZZZ</property>
        <property name="hibernate.c3p0.min_size">5</property>
        <property name="hibernate.c3p0.max_size">20</property>
        <property name="hibernate.c3p0.timeout">1800</property>
        <property name="hibernate.c3p0.max_statements">0</property>
        <property name="hibernate.default_schema">YYYY</property>
        <property name="hibernate.dialect">org.hibernate.dialect.OracleDialect</property>
        <property name="hibernate.show_sql">true</property>
    </session-factory>
</hibernate-configuration>

Related Libraries used:

  • ojdbc6 11.2.0.3.0
  • hibernate 3.1

Problem: The dependencies contained 2 hibernate version 3.1 and 3.0 and ojdbc6 and ojdbc7. (used mvn dependency:tree -Dverbose to got dependency tree)

Solution: Excluded the other versions of hibernate and ojdbc from the dependencies.

            <dependency>
                <groupId>****</groupId>
                <artifactId>****</artifactId>
                <version>****</version>
                <exclusions>
                    <exclusion>
                        <groupId>hibernate</groupId>
                        <artifactId>hibernate</artifactId>
                    </exclusion>
                    <exclusion>
                        <groupId>com.oracle</groupId>
                        <artifactId>ojdbc6</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>
Fatma answered 12/11, 2015 at 16:11 Comment(1)
maybe related if you use a linux distribution #26227844Belshin
S
4

As i can see from the Oracle FAQ, the jdbc driver you are using is not compatible with the Database Version and JDK8.

What are the various supported Oracle database version vs JDBC compliant versions vs JDK version supported? enter image description here

I think this must be your problem. Maybe if you used ojdbc7.jar might help (not sure about this cause I haven't tested it yet - MOST PROBABLY THIS WOULD FAIL)

Suttee answered 13/11, 2015 at 9:1 Comment(2)
I am using JDK8, ojdbc7 12.1 and Oracle Db version is 12.1 but still getting the same problem.Fatma
I am using JDK8, ojdbc7 and Oracle 11.2 , still getting nullpointer errrosMegohm

© 2022 - 2024 — McMap. All rights reserved.