Skip to content

Fail to connect to IBMi from Ubuntu Server #1023

Closed

Description

@cavamacmoe

Hello,

1/
We have installed DB2_RTC_12_1_Linux_x86-64.tar.gz
Using DB2_CUEi_QS_Activation_12.1 we have activated the license.
db2licm -l is showing :
Product name: "DB2 Connect Unlimited Edition for iSeries"
License type: "Client Device"
Expiry date: "Permanent"
Product identifier: "db2consv"
Version information: "12.1"

2/
We have this source code :

import os
import ibm_db

os.environ['IBM_DB_HOME'] = '/opt/ibm/db2/V12.1/'
os.environ['LD_LIBRARY_PATH'] = '/opt/ibm/db2/V12.1/lib/' + (':' + os.environ.get('LD_LIBRARY_PATH', '') if os.environ.get('LD_LIBRARY_PATH') else '')

conn_str = "DATABASE=C6008454;HOSTNAME=cavinfor;PORT=446;PROTOCOL=TCPIP;UID=;PWD=;"

try:
conn = ibm_db.connect(conn_str, '', '')
print("Connexion réussie à DB2")
ibm_db.close(conn)
except Exception as e:
print(f"Échec de connexion: {e}")

3/
Execution fails :
root@SV-NESSIET:/opt/ibm# python3 test.py
Échec de connexion: [IBM][CLI Driver] SQL1598N An attempt to connect to the database server failed because of a licensing problem. SQLSTATE=42968 SQLCODE=-1598

Activity

  1. Earammak commented on Jul 11, 2025

    @Earammak
    Collaborator

    @cavamacmoe , It says that you do not have db2connect license. Please refer to the document for License requirement: https://github.com/ibmdb/python-ibmdb#Licenserequirements

  2. cavamacmoe commented on Jul 11, 2025

    @cavamacmoe
    Author

    I have license
    e have activated the license.
    db2licm -l is showing :
    Product name: "DB2 Connect Unlimited Edition for iSeries"
    License type: "Client Device"
    Expiry date: "Permanent"
    Product identifier: "db2consv"
    Version information: "12.1"

  3. Earammak commented on Jul 11, 2025

    @Earammak
    Collaborator

    @cavamacmoe , Can you share " db2level " command output.

  4. Earammak commented on Jul 11, 2025

    @Earammak
    Collaborator
  5. bimalkjha commented on Jul 11, 2025

    @bimalkjha
    Member

    @cavamacmoe You have installed DB2_RTC client as /opt/ibm/db2/V12.1/ and then installed ibm_db and trying to connect to iSeries server but getting SQL1598N error, right?

    I think the issue lies in how you installed ibm_db. Please note that ibm_db uses db2 odbc driver for connectivity. So, when we install ibm_db, by default ibm_db downloads its own odbc/clidriver from ibm hosted site and use it rather than any existing client/driver in the system. Your RTC client too has odbc driver and you want ibm_db to use it. For that you need to instruct ibm_db to use existing RTC client and do not download its own clidriver by setting IBM_DB_HOME environment variable before installation of ibm_db.

    export IBM_DB_HOME=/opt/ibm/db2/V12.1/
    pip install ibm_db
    

    But, above steps too will not work as ibm_db on linux is a precompiled wheel package which includes clidriver too. So, correct commands would be as below:

    export IBM_DB_HOME=/opt/ibm/db2/V12.1/
    pip install ibm_db --no-binary :all: --no-cache-dir
    

    Above pip command will install ibm_db from source code and not from the precompiled wheel image. So, your system should have gcc compiler to compile native c++ codes of ibm_db which interacts with odbc driver.

    If you install ibm_db using pip install ibm_db --no-binary :all: --no-cache-dir command, it will use /opt/ibm/db2/V12.1/lib/libdb2.so.1 file for connectivity. You have installed license file for it and it should connect to iSeries server without any error.

    But, ibm_db requires odbc header files too during compilation of native c++ code. So, make sure you have /opt/ibm/db2/V12.1/include directory too. If you do not have this directory, installation of ibm_db will fail. I think RTC client do not has include directory which contains SQL and CLI header files. DB2 CLIENT installer comes with include directory. Also, IBM Data Server Driver package comes with include directory.

    Note that you can use ibm_db with IBM Db2 Data Server Driver Package, IBM Db2 Client Package and IBM DB2 Server installations only. The clidriver that ibm_db downloads by default is a minimized version of IBM Db2 Data Sever Package which includes include directory too. The clidriver downloaded from fix-central do not come with include directory.

    If you can get db2connect license file f.e. db2consv_is.lic, you can copy it under ...\site_package\clidriver\license directory. This clidriver you get when you install ibm_db using pip install ibm_db command on Linux. ibm_db uses this clidriver for connectivity and if it has license file under license directory, connection to iSeries will succeed.

    So, you have below options to fix this issue:

    1. Either install DB2 client package or Db2 Data Server driver package then set IBM_DB_HOME and install ibm_db using above command.
    2. Get db2connect license file and copy under clidriver/license directory which will use its site_package/clidriver for connectivity and not /opt/ibm/db2/V12.1/.
    3. Download https://public.dhe.ibm.com/ibmdl/export/pub/software/data/db2/drivers/odbc_cli/v12.1.0/linuxx64_odbc_cli.tar.gz file, untar it to get clidriver directory. Copy clidriver/include directory to /opt/ibm/db2/V12.1/ then set IBM_DB_HOME and install ibm_db. It should work. Just run below commands on your Linux system and it should work:
    cd
    wget https://public.dhe.ibm.com/ibmdl/export/pub/software/data/db2/drivers/odbc_cli/v12.1.0/linuxx64_odbc_cli.tar.gz
    tar -xzf linuxx64_odbc_cli.tar.gz
    cp -r clidriver/include /opt/ibm/db2/V12.1/
    export IBM_DB_HOME=/opt/ibm/db2/V12.1/
    pip uninstall ibm_db
    pip install ibm_db --no-binary :all: --no-cache-dir
    python test.py
    

    Let us know which one you tried. Thanks.

  6. cavamacmoe commented on Jul 15, 2025

    @cavamacmoe
    Author

    @bimalkjha :
    I tried "pip install ibm_db --no-binary :all: --no-cache-dir" before but include files were missing
    "wget https://public.dhe.ibm.com/ibmdl/export/pub/software/data/db2/drivers/odbc_cli/v12.1.0/linuxx64_odbc_cli.tar.gz" solve my problem.

    Thanks you very much

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions