Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't connect to Oracle 19.3 with 19.3 JDBC driver

Tags:

java

oracle

jdbc

We have a project running with an Oracle 19.3 database, and a Java application using the Oracle 19.3 JDBC driver (which is available on Maven Central). On Windows with JRE 1.8, everything is fine, but when I run either on our build server or in WSL Ubuntu with OpenJDK 11.0.3 it refuses to connect to the database. Specifically:

ERROR: Unexpected error
java.sql.SQLRecoverableException:
Unable to obtain connection from database (jdbc:oracle:thin:@//<host>:<port>/<db>) for user '<user>': IO Error: Invalid argument, Authentication lapse 0 ms.
--------------------------------------------------------------------------------------------------------------------------------------------------------------------
SQL State  : 08006
Error Code : 17002
Message    : IO Error: Invalid argument, Authentication lapse 0 ms.

        at JuliasApplication.openConnection(JdbcUtils.java:60)
        ...
Caused by: java.sql.SQLRecoverableException: IO Error: Invalid argument, Authentication lapse 0 ms.
        at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:874)
        at oracle.jdbc.driver.PhysicalConnection.connect(PhysicalConnection.java:793)
        at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:57)
        at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:747)
        at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:562)
        ...
Caused by: java.io.IOException: Invalid argument, Authentication lapse 0 ms.
        at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:870)
        ... 12 more
Caused by: java.io.IOException: Invalid argument
        at java.base/sun.nio.ch.SocketChannelImpl.sendOutOfBandData(Native Method)
        at java.base/sun.nio.ch.SocketChannelImpl.sendOutOfBandData(SocketChannelImpl.java:521)
        at java.base/sun.nio.ch.SocketAdaptor.sendUrgentData(SocketAdaptor.java:323)
        at oracle.net.nt.TcpNTAdapter.sendUrgentByte(TcpNTAdapter.java:433)
        at oracle.net.ns.NSProtocolNIO.negotiateConnection(NSProtocolNIO.java:159)
        at oracle.net.ns.NSProtocol.connect(NSProtocol.java:340)
        at oracle.jdbc.driver.T4CConnection.connect(T4CConnection.java:1596)
        at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:588)
        ... 12 more

If I switch in the 18.3 JDBC driver everything is fine in both environments; if I switch in an 18.3 database everything is fine in both environments. That does give us a workaround for now, but it feels very uncomfortable that we don't understand what's going on. And I can't find anything online about an "Authentication lapse". Can anyone see any clues which would explain the failure?

like image 269
Julia Hayward Avatar asked Oct 10 '19 09:10

Julia Hayward


People also ask

What JDBC version is compatible with Oracle 19c?

For Oracle 19c, you can use either ojdbc8. jar or ojdbc10. jar. OJDBC10 is compiled with Java 10 and will not work unless you're running Bamboo 8 with Java 11.

Does ojdbc7 work with Oracle 19c?

As noted, ojdbc6 and 7 are both successfully used with 19c.

What is the latest version of JDBC driver?

Version 11.2 is the latest general availability (GA) version. It supports Java 8, 11, 17, and 18. If you need to use an older Java runtime, see the Java and JDBC specification support matrix to see if there's a supported driver version you can use.

Which Oracle JDBC driver should I use?

Which driver should I use? The best choice is to use Oracle JDBC thin driver. All the new enhancements and features are implemented only on JDBC Thin driver. If you are using a non-TCP/IP network you must use the OCI driver.


2 Answers

It looks like the underlying Socket implementation is not allowing OOB. As a workaround, you can disable the OOB check by setting the connection property CONNECTION_PROPERTY_THIN_NET_DISABLE_OUT_OF_BAND_BREAK to "true". Please refer this link : https://docs.oracle.com/en/database/oracle/oracle-database/20/jajdb/oracle/jdbc/OracleConnection.html#CONNECTION_PROPERTY_THIN_NET_DISABLE_OUT_OF_BAND_BREAK

The link above no longer mentions the "out of band break" issue, so here's some alternatives:

  • put DISABLE_OOB=on in your sqlnet.ora file, per this article.
  • for your java apps put -Doracle.net.disableOob=true on the command line
  • for apps like SQL Developer you can add AddVMOption -Doracle.net.disableOob=true to your sqldeveloper.conf.
like image 181
Aram Avatar answered Oct 17 '22 00:10

Aram


I had the same issue with an Oracle 19c docker container, and after browsing half of the internet, I realized that the problem came from the fact that I used localhost as the Host, which for some reason is not supported by the 19.3.0.0+ Oracle driver.

After configuring the host with the IP address of the docker network interface (172.17.0.2 in my case), I could connect to Oracle server.

Hope this can help you as well.

like image 23
Manu D. Avatar answered Oct 17 '22 02:10

Manu D.