3

I am trying to migrate a project from Java 8 to Java 11, which uses ojdbc. I am using a class which extends PoolDataSourceImpl, which implements PooLDataSource, which extends javax.sql.DataSource and while trying to built it with maven it gives this error:

Compilation failure [ERROR] createConnectionBuilder() in oracle.ucp.jdbc.PoolDataSourceImpl cannot implement create ConnectionBuilder() in javax.sql.DataSource [ERROR] return type oracle.ucp.jdbc.UCPConnectionBuilder is not compatible with java.sql.ConnectionBuilder

Does anyone have any suggestions?

Dragos
  • 41
  • 1
  • 3

5 Answers5

2

This is interface incompatibility. javax.sql.DataSource defines a method

default ConnectionBuilder createConnectionBuilder() throws SQLException

And as per the contract the return value requires to be of type ConnectionBuilder.

If you take a look at documentation of oracle.ucp.jdbc.PoolDataSourceImpl, it defines the method as

public UCPConnectionBuilder createConnectionBuilder()

whereas oracle.ucp.jdbc.UCPConnectionBuilder is not a subtype of java.sql.ConnectionBuilder.

Now unless Oracle releases a never version of oracle.ucp.jdbc.UCPConnectionBuilder interface that extends java.sql.ConnectionBuilder, you will not be able to interchange UCP PoolDataSource with javax.sql.DataSource.

The latest release at this point appears to be UCP 19.3, which would still hit the same problem which is unfortunate since 19.3 is advertised as JDK11 compliant. Please raise a bug against Oracle UCP to make the maintainers aware of the new entrant createConnectionBuilder in the DataSource interface.

In the intrim, if it is feasible, you may fall back to using 11g release 2 of UCP (not 12, not 19) which does not have the method createConnectionBuilder on the PoolDataSource interface. Not an ideal situation, since you are giving up on a decade worth of improvements in UCP by going back to 11g.

Ashwin Prabhu
  • 9,285
  • 5
  • 49
  • 82
2

This problem is resolved in 21.3 with ucp11.jar (a version of UCP compiled with JDK11). In this version UCP oracle.ucp.jdbc.UCPConnectionBuilder extends java.sql.ConnectionBuilder.

https://repo1.maven.org/maven2/com/oracle/database/jdbc/ucp/21.3.0.0/ucp-21.3.0.0.jar

Jean de Lavarene
  • 3,461
  • 1
  • 20
  • 28
1

The problem is that you try to subclass PoolDataSourceImpl which is a vendor-specific class compiled with JDK8 and we do not support extending our classes unless we explicitly suggest to do so, as in this blog; and this is true for all software vendors. A part from this restriction, our drivers (ojdbc8.jar, ucp.jar) are forward compatible with newer JDK releases (i.e., work with JDK11) and database releases.

Kuassi Mensah
  • 274
  • 1
  • 4
  • 1
    The extension is by UCP jar. It is plain bad luck that release 19 of UCP introduced a new method createConnectionBuilder at the same time JDK 10 introduced the exact same name in the DataSource interface that PoolDataSource extends. SO the extension is by Oracle. – Ashwin Prabhu Apr 17 '20 at 06:21
  • That's right. UCP implements createConnectionBuilder that returns an OracleConnectionBuilder. In Java 8 that method is Oracle proprietary but in Java 9 javax.sql.DataSource defines createConnectionBuilder returning a java.sql.DataSource. This works fine in Java 9 because oracle.jdbc.OracleConnectionBuilder extends java.sql.ConnectionBuilder in ojdbc9|10|11.jar. But UCP is built with Java 8 and ojdbc8.jar so this doesn't work. – Kuassi Mensah May 08 '20 at 18:50
0

With this issue proxying with interface-based proxy on PoolDataSource will never work. A bug is logged on oracle ucp for the same. I even posted a forum query with no reply on this https://community.oracle.com/thread/4325841.

Lakshmi
  • 31
  • 1
0

In my case I was using Java 8 but still getting this exception and the root cause of the issue is Oracle Client was upgraded by DB Team and the ORACLE_HOME configuration has to change accordingly in your application server. Example: Old: Oracle client version 12.x.x New: Oracle client version 19.x.x

Elias
  • 664
  • 2
  • 11
  • 23