Wednesday, October 9, 2024

Oracle Connection to Docker Container Failed on Ubuntu 24.04

What Was the Problem?

After upgrading to Ubuntu 24.04, connections to an Oracle database in a Docker container failed.  These connections were working before the upgrade.

  • SQL*Plus: ORA-12637: Packet receive failed
  • "sqlnet.ora" (TRACE_LEVEL_CLIENT=user): Fatal NI connect error 12170
  • Oracle SQL Developer Extension for VSCode: Failed to connect

It Was Not AppArmor

I found many entries about Docker not starting after an Ubuntu upgrade.  While I don't know the root cause of this problem, no changes to AppArmor are needed to solve this problem.

What is the Interim Fix?

I found several fixes. I included links to websites.

SQL*Plus/SQL*Net:

Update "sqlnet.ora" File - Add "DISABLE_OOB=ON" to disable Out-of-Band communication.  Note: The location of the "sqlnet.ora" file can be based on the environment settings of ORACLE_HOME or TNS_ADMIN.

Oracle SQL Developer Extension for VSCode

Update "Advanced" Tab in "Update Connection" - Add a new name "oracle.net.disableOob" with a value of "true" to disable Out-of-Band communication.

What is the Root Cause?

I don't know.  I have not found it.  I assume there is a loss of functionality when Out-of-Band communication is not available for an Oracle client.  I will continue to follow this and add updates as I find them.

Friday, October 4, 2024

Unloading/Loading NLS (National Language Support) Data in Oracle

What is the problem?

Every Oracle database has 2 different character sets for "string" data types.  These character sets are defined whenever a database is created.

  • CHARACTER SET - This is the main character set for the database. It is set for specific environment and application needs.  This character set is normally used to store and handle all string data.
  • NATIONAL CHARACTER SET - This is the NLS (National Language Support) character set and is available for multi-lingual string data storage on all Oracle databases.  It can be set to one of these UNICODE character sets: "AL16UTF16" or "UTF8".
Oracle's DB Sample Schemas use the NLS character set for multi-lingual string data.  This data is loaded with SQL INSERT statements.  However, we have a need to unload and load this data to/from text files.

The problem is that text files will generally have string data for the database's main character set.  A different technique is needed to unload and load the NLS string data.  Oracle's DB Sample Schemas uses the UNISTR format to segregate NLS string data from string data that uses the database's main character set.

We will be using the UNISTR format as well.

How to Unload NLS String Data to a Text File?

The US7ASCII character set is a common subset of almost all main character sets for an Oracle database.  This is important because any NLS string data saved to a text file needs a common format with the database's main character set.  Also note the US7ASCII character set only uses the 7 LSBs (least significant bits) for each character.  Characters in this range can be found when Oracle's ASCII function returns decimal values between 0 and 127.  Additionally, the "\" character needs to be "escaped" with another "\" character.

We used the following function to encode database NLS string data to UNISTR format.  The resulting string data from this function will only contain US7ASCII characters and can be safely stored in a text file.