2
votes

I'm attempting to bring up an ODBC connection to an Informix DB inside a Perl script (v5.12.4) using DBD::ODBC. I've read through lots of docs and seem to be hitting a wall and was hoping to get some tips here.

I have unixODBC 2.2.14 installed with empty odbcinst.ini and odbc.ini files (not good, I know). I've also downloaded the CSDK for Informix from IBM's site. If I check the available drivers for DBI, Informix is listed there as well.

I guess my issues are related to populating the .ini files with the correct info for the drivers and dsn. I'm not sure where the Informix drivers are, how I reference them or the syntax of the dsn. I've been using DBI with mysql for a while just fine but ODBC seems to be more in depth and a bit over my head right now.

When I attempt to run a script to connect, I get:

DBI connect........failed: [unixODBC][Driver Manager]Data source name not found, and no default driver specified (SQL-IM002) at Informix.pl line 20

If I'm missing any important details in the post please let me know and I'll include.

Thanks!

UPDATE

I got some help on a separate post to find that Java and my OS don't play nice and so I wasn't able to get the CSDK installed correctly. So, I ripped out Ubuntu and installed SuSE. I have (I hope) installed the CSDK correctly now and have updated the .ini files. On a side note, I'm not able to run nm to view symbols but I do have several .so files in the /opt/IBM/informix/lib/ dir which I'm trying to reference in my odbcinst.ini file. When I run the isql connection, I'm getting :

[01000][unixODBC][Driver Manager]Can't open lib '/opt/IBM/informix/lib/nameofdriver.so.   : file not found

Do you have any recommendations on this one? I've checked the file for rogue spaces/characters and I'm running the connection request as root. Any help is appreciated. Thanks!

1

1 Answers

2
votes

Did you read README.informix included with DBD::ODBC? I know it is very old but it at least gives you a clue that you normally set INFORMIXDIR to where the CSDK is unpacked and the client libraries are/were in $INFORMIXDIR/lib/cli.

You need to find which shared object is the Informix ODBC driver so look in the SDK for files ending in .so and if that still leaves you too many to guess try running nm on them and look for symbols like SQLAllochandle (which all ODBC drivers need). Once you've located the driver you need to create your ini files which can be located with "odbcinst -j". Add something like the following to your odbcinst.ini file:

[informix]
Description=Informix ODBC driver
Driver=/path/to/informix_odbc_driver_shared_object
DontDLClose=1

Then you need to create a DSN in your odbc.ini that looks something like:

[mydsn]
Driver = informix
Database=myDataBase;
Host=192.168.10.10;
Server=db_engine_tcp;
Service=1492;
Protocol=onsoctcp;

I stole those from a connection strings site so you should check them with you informix docs.

Then you can use:

isql -v mydsn myusername mypassword

to test the connection out.

I would happily accept any changes for README.informix once you get it working.