IBM Support

ibm-iaccess for Linux ODBC Configuration

Troubleshooting


Problem

The unixODBC driver manager for Linux used to provide a GUI to manage ODBC drivers and data sources (DSN). This was started with the "ODBCConfig" command. Modern Linux distributions typically do not provide that tool, and DSNs must be created manually.

Resolving The Problem

Prerequisite packages:
To create the DSN(s) manually:
1. Execute the odbcinst -j command to obtain the locations of your unixODBC installation and configuration files.
2. Use the following sample entry in the odbc.ini. to create a DSN that can be used to make ODBC connections to the IBM i.
3. Remove all "<" and ">" characters and substitute italicized contents with valid values for your environment.

[<MyDSNName>]
Description             = IBM i Access ODBC Driver 64-bit
Driver                  = IBM i Access ODBC Driver 64-bit
System                  =
<IBMiSystemName or IP>
UserID                  =
Password                =
Naming                  = 0
DefaultLibraries        = QGPL
Database                =
ConnectionType          = 0
CommitMode              = 2
ExtendedDynamic         = 1
DefaultPkgLibrary       = QGPL
DefaultPackage          = A/DEFAULT(IBM),2,0,1,0,512
AllowDataCompression    = 1
MaxFieldLength          = 32
BlockFetch              = 1
BlockSizeKB             = 128
ExtendedColInfo         = 0
LibraryView             = ENU
AllowUnsupportedChar    = 0
ForceTranslation        = 0
Trace                   = 0

 
ODBC applications can then connect to Db2 for i by referencing the DSN name <MyDSNName>. For example:
$ isql <MyDSNName> <MyUSRPRF> <MyPASSWD>
Alternatively, here is a sample PHP script that uses a "DSN-less" connection:
<?php

$conn = odbc_connect("DRIVER={IBM i Access ODBC Driver 64-bit};System=my_IBMihostname", '<MyUSRPRF>', '<MyPASSWD>');
$a = 'Doe';

$stmt    = odbc_prepare($conn, 'select * from qiws.qcustcdt where LSTNAM = (?)');
$success = odbc_execute($stmt, array($a));

odbc_result_all($stmt);
odbc_free_result($stmt);
odbc_close($conn);

?>

[{"Product":{"code":"SWG60","label":"IBM i"},"Business Unit":{"code":"BU058","label":"IBM Infrastructure w\/TPS"},"Component":"Access for Linux","Platform":[{"code":"PF016","label":"Linux"}],"Version":"Version Independent","Edition":"Advanced;Enterprise;Workstation","Line of Business":{"code":"LOB57","label":"Power"}}]

Document Information

Modified date:
11 October 2022

UID

nas8N1020437