9

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?

Julia Hayward
  • 1,987
  • 1
  • 14
  • 16

3 Answers3

8

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:

inanutshellus
  • 9,683
  • 9
  • 53
  • 71
Aram
  • 131
  • 1
  • 4
  • Excellent - that works! I assume it's a change in the driver implementation at v19.3, so we only need to set it if we see that driver version? – Julia Hayward May 29 '20 at 12:47
  • There is a fourth option that can be done to use the above solutions that @Aram mentioned. You can add "?oracle.net.disableOob=true" to the end of your JDBC Connection URL if neither of those options fit your needs. Example - jdbc:oracle:thin:@//hostname.com:1521/SCHEMA_NAME?oracle.net.disableOob=true – Cody Dec 13 '22 at 15:06
1

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.

Manu D.
  • 357
  • 3
  • 8
  • Is that the IP address as returned by https://stackoverflow.com/questions/17157721/how-to-get-a-docker-containers-ip-address-from-the-host ? I get 172.18.0.2 but that returns `The Network Adapter could not establish the connection` – Julia Hayward May 27 '20 at 09:47
  • I use the address returned by the Unix command: `ip -4 address show | grep docker0 | grep inet | awk '{print $2}' | sed -e 's@/.*@@g'` – Manu D. Sep 17 '20 at 21:27
0

You must use ojdbc10.jar that is compliant with JDK10. Refer to the FAQ (What are the Oracle JDBC releases Vs JDK versions?) for more details.

19.3 ojdbc10.jar with JDK10, JDK11 and ojdbc8.jar with JDK8, JDK9, JDK11 18.3 ojdbc8.jar with JDK8, JDK9, JDK10, JDK11

Nirmala
  • 1,278
  • 1
  • 10
  • 11
  • I looked at that page; I'm using OpenJDK11, it claims `ojdb8.jar` is OK with JDK11. (And note, no advice on higher JDKs) – Julia Hayward Feb 11 '20 at 16:42
  • If you are using JDK11 then, you can use ojdbc8.jar as it is compiled with JDK8 but can be used with JDK10 and JDK 11. FAQ will be updated with this information soon. – Nirmala Feb 12 '20 at 22:55