utPLSQL/utPLSQL-cli

utPLSQL CLI failing with Incompatible version of libocijdbc error

indrajitagasti opened this issue · 13 comments

I have downloaded the latest utplsql CLI and the related odbcjar8 from oracle and trying to execute a few commands. The sqlplus connection to the database is working fine.
Here is the sample code that I am executing. It appears to be a mis-match between jdbc and jdbc-OCI driver. How do i fix it?

C:\MySoftwares\UTPLSQL\utPLSQL\utPLSQL-cli\bin>utplsql info
cli 3.1.2-SNAPSHOT.local
utPLSQL-java-api 3.1.2.271

C:\MySoftwares\UTPLSQL\utPLSQL\utPLSQL-cli\bin>SQLPLUS scott/tiger@pdborcl

SQL*Plus: Release 12.1.0.2.0 Production on Sun Nov 18 14:18:24 2018

Copyright (c) 1982, 2014, Oracle. All rights reserved.

ERROR:
ORA-28002: the password will expire within 4 days

Last Successful login time: Sun Nov 18 2018 02:07:39 +00:00

Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options

SQL> exit
Disconnected from Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options

C:\MySoftwares\UTPLSQL\utPLSQL\utPLSQL-cli\bin>utplsql reporters scott/tiger@pdborcl
Exception in thread "main" java.lang.Error: Incompatible version of libocijdbc[Jdbc:122010, Jdbc-OCI:121020
at oracle.jdbc.driver.T2CConnection$1.run(T2CConnection.java:4161)
at java.security.AccessController.doPrivileged(Native Method)
at oracle.jdbc.driver.T2CConnection.loadNativeLibrary(T2CConnection.java:4154)
at oracle.jdbc.driver.T2CConnection.logon(T2CConnection.java:453)
at oracle.jdbc.driver.PhysicalConnection.connect(PhysicalConnection.java:688)
at oracle.jdbc.driver.T2CDriverExtension.getConnection(T2CDriverExtension.java:60)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:691)
at com.zaxxer.hikari.util.DriverDataSource.getConnection(DriverDataSource.java:117)
at com.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:375)
at com.zaxxer.hikari.pool.PoolBase.newPoolEntry(PoolBase.java:204)
at com.zaxxer.hikari.pool.HikariPool.createPoolEntry(HikariPool.java:445)
at com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:516)
at com.zaxxer.hikari.pool.HikariPool.(HikariPool.java:116)
at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:97)
at org.utplsql.cli.datasource.TestedDataSourceProvider.setThickOrThinJdbcUrl(TestedDataSourceProvider.java:48)
at org.utplsql.cli.datasource.TestedDataSourceProvider.getDataSource(TestedDataSourceProvider.java:37)
at org.utplsql.cli.DataSourceProvider.getDataSource(DataSourceProvider.java:31)
at org.utplsql.cli.ReportersCommand.run(ReportersCommand.java:40)
at org.utplsql.cli.Cli.runWithExitCode(Cli.java:38)
at org.utplsql.cli.Cli.main(Cli.java:18)

C:\MySoftwares\UTPLSQL\utPLSQL\utPLSQL-cli\bin>

Looks like you have compatibility issues between OCI and JDBC libraries that you use:
The error message says:
Incompatible version of libocijdbc[Jdbc:122010, Jdbc-OCI:121020

Can you make sure that both your local OCI and JDBC drivers are of the same version?

Let me know if that helps.

12.1.0.2.0 - is your OCI (same as your Database client software)
12.2.0.1.0 - is the version of JDBC driver (the error message contains version numbers without the . )

So you should probably put the jdbc driver version 12.1.0.2.0 into utplsql-cli/lib directory.

You will probably have 12.1.0.2.0 version of JDBC driver in your oracle home somewhere.

Thanks Jacek.
I have put ojdbc7.jar and removed ojdbc8.jar from the C:\MySoftwares\UTPLSQL\utPLSQL\utPLSQL-cli\lib directory and now I am getting the below error, which seems to be a division by zero error.

C:\MySoftwares\UTPLSQL\utPLSQL\utPLSQL-cli\bin>utplsql reporters scott/tiger@pdborcl
java.lang.ArithmeticException: / by zero
at oracle.jdbc.driver.OraclePreparedStatement.(OraclePreparedStatement.java:1387)
at oracle.jdbc.driver.T2CPreparedStatement.(T2CPreparedStatement.java:109)
at oracle.jdbc.driver.T2CDriverExtension.allocatePreparedStatement(T2CDriverExtension.java:81)
at oracle.jdbc.driver.PhysicalConnection.prepareStatementInternal(PhysicalConnection.java:2013)
at oracle.jdbc.driver.PhysicalConnection.prepareStatement(PhysicalConnection.java:1960)
at oracle.jdbc.driver.T2CConnection.prepareStatement(T2CConnection.java:57)
at oracle.jdbc.driver.PhysicalConnection.prepareStatement(PhysicalConnection.java:1866)
at oracle.jdbc.driver.T2CConnection.prepareStatement(T2CConnection.java:57)
at com.zaxxer.hikari.pool.ProxyConnection.prepareStatement(ProxyConnection.java:317)
at com.zaxxer.hikari.pool.HikariProxyConnection.prepareStatement(HikariProxyConnection.java)
at org.utplsql.api.db.DefaultDatabaseInformation.getUtPlsqlFrameworkVersion(DefaultDatabaseInformation.java:15)
at org.utplsql.api.compatibility.CompatibilityProxy.doCompatibilityCheckWithDatabase(CompatibilityProxy.java:64)
at org.utplsql.api.compatibility.CompatibilityProxy.(CompatibilityProxy.java:53)
at org.utplsql.api.compatibility.CompatibilityProxy.(CompatibilityProxy.java:34)
at org.utplsql.cli.ReporterFactoryProvider.createReporterFactory(ReporterFactoryProvider.java:25)
at org.utplsql.cli.ReportersCommand.run(ReportersCommand.java:43)
at org.utplsql.cli.Cli.runWithExitCode(Cli.java:38)
at org.utplsql.cli.Cli.main(Cli.java:18)

I ran out of ideas for now, maybe @pesse will be able to give some better advice.

No problem Jacek. Thanks a lot for your help.

Hi,
I have managed to workaround the above division by zero problem.
The password of SCOTT user was expiring. When I reset the password to a new password, the / by zero exception was not visible anymore.
The below thread discussed a similar problem.
https://stackoverflow.com/questions/10945359/java-lang-arithmeticexception-when-attempting-to-get-connection-in-oracle-11-2-0

However, now I am getting a different error after copying ojdbc7.jar in lib directory.
C:\MySoftwares\UTPLSQL\utPLSQL\utPLSQL-cli\bin>utplsql reporters scott/tigernew@pdborcl
Exception in thread "main" java.lang.NoClassDefFoundError: oracle/jdbc/OracleType
at org.utplsql.api.reporter.inspect.ReporterInspector310.getDescription(ReporterInspector310.java:65)
at org.utplsql.api.reporter.inspect.ReporterInspector310.getReporterInfo(ReporterInspector310.java:49)
at org.utplsql.api.reporter.inspect.ReporterInspector310.(ReporterInspector310.java:33)
at org.utplsql.api.reporter.inspect.ReporterInspector.create(ReporterInspector.java:41)
at org.utplsql.cli.ReportersCommand.run(ReportersCommand.java:45)
at org.utplsql.cli.Cli.runWithExitCode(Cli.java:38)
at org.utplsql.cli.Cli.main(Cli.java:18)
Caused by: java.lang.ClassNotFoundException: oracle.jdbc.OracleType
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 7 more

C:\MySoftwares\UTPLSQL\utPLSQL\utPLSQL-cli\bin>

pesse commented

The Enum OracleType is not part of ojdbc7 (12.1 release) library. It's not possible to run the cli or java-api with ojdbc7, minimum version is ojdbc8 (12.2 release).
However, your main problem seems to be that you have a 12.1 instant-client (thick, oci) installed on your machine, so cli tries to use that instead of the provided thin-driver (ojdbc8).

One possibility you have is to upgrade your instant-client to at least 12.2 (this doesn't affect your local database, you can also access 12.1 with a 12.2 client).

One thing I could imagine doing on our side is to allow to specify the full connect string as parameter:

utplsql run jdbc:oracle:thin:@user/pw@server:1521/service

If full connect string is provided, we would then skip trying using thick-driver so you would always use the provided thin-driver.

Could we ignore thick driver if it is incompatibe?

pesse commented

Hm, good idea.
Will require lots of testing though I guess.

Hi,
Managed to get it working now.
Below is what I did:

  1. Upgraded my local 12CR1 instance to 18C
  2. Copy the ojdbc8.jar file from <ORACLE_HOME>\jdbc\lib directory
  3. Paste it to utPLSQL-cli\lib directory.
    There is a small difference in size between the ojdbc8.jar file posted in https://www.oracle.com/technetwork/database/features/jdbc/jdbc-ucp-122-3110062.html
    and
    the one that is shipped with Oracle18C server software.
    The oracle 18C ojdbc8.jar is 4,161,744 bytes, whereas the other one in the link above is 4,036,257 bytes.
    I believe ojdbc8.jar shipped with Oracle 18C is the latest and should be the one to be used.

Hi,
I am using DataGrip DB-221.5591.57 version. I'm trying to make an OCI connection with DataGrip, but I get the error Incompatible version of libocijdbc[Jdbc:211000, Jdbc-OCI:213000.

I am using instantclient_21_3. I added it to the environment variables.

PS: I can successfully connect with SqlDev.

Error images are below;

Driver;
Driver

Connection;
connection

Failed;
Failed

pesse commented

Hey @oballi
I'm not sure what exactly you are trying to do and how this is related to utPLSQL-cli
Sam