Score:0

Connect to remote Database using DB2 from Ubuntu

ck flag

I am trying to setup an Ubuntu VM as a php test development server.

However, I am having trouble connecting to our Remote Database with db2.

I am new to Ubuntu/configuring db2 and have been following this guide (the first comment):

https://www.php.net/manual/en/ibm-db2.installation.php

I am able to run the db2_connect() function in php however I get this response:

ERROR: [IBM][CLI Driver] SQL30081N A communication error has been detected. Communication protocol being used: "TCP/IP". Communication API being used: "SOCKETS". Location where the error was detected: "127.0.0.1". Communication function detecting the error: "connect". Protocol specific error code(s): "111", "*", "*". SQLSTATE=08001 SQLCODE=-30081

I have searched up the error code, and 111 stands for Access denied but I am not convinced the driver is even communicating with the DB because I can type in any random assortment of IP addresses/host names and I still get the same error.

From my Ubuntu VM I can ping the DB, and the Firewall is set so that all connections are allowed from the Ubuntu VM to the DB and vice versa - another reason I am unconvinced the Ubuntu VM is even communicating with the DB

I have configured the db2cli.ini and db2dsdriver.ini to the best of my ability and will gladly on request post those files for further inspection but atm I'd like to keep the post short and to the point.

I am running Ubuntu 22.04.2 LTS, running PHP8.2 and installed the DB2 v11.5.8 Data Server Driver Package

Some troubleshooting tips/pointers in the right direction would be incredibly helpful.

I was previously following this guide: https://fractio.nl/2007/10/26/setting-up-unixodbc-with-a-remote-db2/

But after receiving random errors such as is the driver working? I did my best to remove it and try again with the php.net link

mao avatar
pk flag
mao
clidriver works fine for me from both 18.04 and 20.04 connecting to remote Db2 databases. Just means your configuration is dodgy. If you already configured db2dsdriver.cfg (as per your question), does the `db2cli validate` succeed? Have you tried a `db2cli validate -connect -dsn XXX -user YYY -passwd ZZZ` to prove your hostname, port-number, database details (and whatever other parameters you configured inside the db2dsdriver.cfg) are all correct ? If you cannot get that working then php will not work.
BoogaBooga avatar
ck flag
Hi Mao, thanks for the reply and sorry for my late answer. I have been able to move past that snag in configuring the webserver but am now confronted with another problem: `SQL1598N An attempt to connect to the database server failed because of a licensing problem.` I don't have access to the db2 license so I think I am stuck unless you can shed some light on the issue?
mao avatar
pk flag
mao
You should not ask a new question in a comment! It should be a different question, but in this case it is a frequently asked question, see https://stackoverflow.com/questions/76403227/ibmcli-driver-sql1598n-an-attempt-to-connect-to-the-database-server-failed
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.