... you want to build a web page? With Apache's web server XAMPP and Db2? Well, then:
Instead of the last sentence, I should be more accurate: There is a general-purpose type of connection from PHP to database management systems: PDO (Persistent Data Objekt), working with MySQL/MariaSQL, Db2, and many others. But for Db2, you can use yet another type of connection, ibm_db2, which offers Db2 specific features on top. Important for my web application: Only with ibm_db2, you can invoke SQL with CTEs including recursion and Table UDFs (CTE: Common Table Expression; UDF: User-Defined Function).
This tip explains the setups for both types of connection
between PHP and Db2: PDO_IBM and ibm_db2.
The tip does not include the usage of these connection types.
You might be in a similar situation as I was: I wasn't able to connect to Db2 for Linux.
For me at least, the offical documentation was too short. I needed help.
.. consists of three files you can download:
a)
On the web, there are a lot of hints saying that the environment for the CRON job is not set up as you might asssume,
e.g., for CRON, the PATH value is probably different from your userid's PATH value.
Let's assume that you want to start "myscript.sh" every 30 minutes after the hour, your initial crontab entry looks like:
30 * * * * myscript.sh
If this script is not found [remember: PATH value], specify instead:
30 * * * * /full-path/myscript.sh
In my case, this produced the error message above.
I tried the following: For Setting all the necessary environment variables as needed, I included "/home/db2inst1/sqllib/db2profile"
into "myscript.sh". But this didn't solve the problem.
b)
Next hint on the web
[https://community.spiceworks.com/topic/2363594-sql10007n-message-1390-could-not-be-retrieved-reason-code-3]
states: "-1390" (in the error message above) is the SQL code, so issue: "db2 ? sql1390".
This will tell you that DB2INSTANCE is not set properly.
I therefore set DB2INSTANCE inside "myscript.sh" before connecting to the database,
but I still got the same error message as before.
So I enhanced my CRONTAB entry to:
30 * * * * DB2INSTANCE=db2inst1; /full-path/myscript.sh [db2inst1 being the name of the instance]
This finaly worked. [Remark: I didn't check whether ATTACH inside "myscript.sh" would have solved the problem, too.]