Problem with DB2 ODBC on Windows Server

Are you using LiveCode to create server scripts or CGIs?

Moderators: Klaus, FourthWorld, heatherlaine, kevinmiller, robinmiller

Post Reply
edgore
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 197
Joined: Wed Jun 14, 2006 8:40 pm

Problem with DB2 ODBC on Windows Server

Post by edgore » Wed Feb 06, 2013 5:02 am

I have a situation where I have to do an SQL query to a DB2 database. I have the IBM DB2 ODBC drivers installed, and everything works perfectly in the development environment.

However, when I take the same script and run it as part of an .lc file on an apache instance on the same machine it get an error from the ODBC driver - "[IBM][CLI Driver] SQL8002N An attempt to connect to a host failed due to a missing DB2 Connect product or invalid license. SQLSTATE=42968".

Apparently IBM has things set up so taht there is a license file on the machine, in a particular directory taht is checked by the odbc driver. My current theory is that everything is working in the development environment because that's running under my user ID. I assume that the livecode engine is executing as if it were run by apache and that service is running under the system acct, and that therefore the driver is also running as if it's being executed byt he system acct. Thing is that the system account has access to read all of the files that it needs to access the license info. In fact, as an experiment I put the system acct in the administraotrs group - the same one I am in - and it still generates the error.

I have been working with IBM on this, and they are trying to figure out what is going on - they are convinced that it should work, since all of this is on the same machine and the access rights look right - but I figured I would at least check in and see if anyone else has seen anything like this happen.

bangkok
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 928
Joined: Fri Aug 15, 2008 7:15 am

Re: Problem with DB2 ODBC on Windows Server

Post by bangkok » Wed Feb 06, 2013 10:34 am

I think you should give us more... details.

You're fine with a Desktop LiveCode, but with a LiveCode Server it doesn't work, right ? Or you are talking about the old "CGI" RunRev method ?

sturgis
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1682
Joined: Sat Feb 28, 2009 11:49 pm

Re: Problem with DB2 ODBC on Windows Server

Post by sturgis » Wed Feb 06, 2013 3:39 pm

There may be an environment variable that points to the license file when in your user acct and running from the IDE. You might look and see what variables are available from the IDE, and confirm or deny this. If that is the case then setting the variable inside your lc server script (or as mentioned, with the cgi method) and THEN trying to connect might help.

edgore
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 197
Joined: Wed Jun 14, 2006 8:40 pm

Re: Problem with DB2 ODBC on Windows Server

Post by edgore » Wed Feb 06, 2013 6:10 pm

Correct - I am fine running in the livecode development environment, but when I try to run it under livecide server (the actual livecode server platform, not trying to run a stack as a CGI) I get the error.

Sturgis - I think you are on to something with the environment variables. I opened up the development environment and looked to see what environment variables it listed, then tested in the server environment put using put $PATH, etc for each of the $variables that shows up in the deve environment and none of them produce anything in the server environment. So, I tried setting them using put "whateverwasinthedevenvironment" into $PATH, but that doesn't seem to have done anything to fix the problem. Does setting the $variable within livecode set teh environmental variable, or am I going to need to do somethign like shelling out and running a batch file? I've never had to deal with anything like this before.

sturgis
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1682
Joined: Sat Feb 28, 2009 11:49 pm

Re: Problem with DB2 ODBC on Windows Server

Post by sturgis » Wed Feb 06, 2013 6:25 pm

edgore wrote:Correct - I am fine running in the livecode development environment, but when I try to run it under livecide server (the actual livecode server platform, not trying to run a stack as a CGI) I get the error.

Sturgis - I think you are on to something with the environment variables. I opened up the development environment and looked to see what environment variables it listed, then tested in the server environment put using put $PATH, etc for each of the $variables that shows up in the deve environment and none of them produce anything in the server environment. So, I tried setting them using put "whateverwasinthedevenvironment" into $PATH, but that doesn't seem to have done anything to fix the problem. Does setting the $variable within livecode set teh environmental variable, or am I going to need to do somethign like shelling out and running a batch file? I've never had to deal with anything like this before.
Yes, setting the $ variable should set it for the current session, so you would have to set things each time. The chance that it is PATH that is the culprit in this case is slim. You're not firing up an executable. If it is an environment variable problem it is most likely named something distinctive. Also, if you are using a dsn file that is available on your dev machine but not available on the server machine, that might be an issue too. (or define the dsn on the machine... I don't know enough about odbc or what os your server runs to answer those questions)

edgore
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 197
Joined: Wed Jun 14, 2006 8:40 pm

Re: Problem with DB2 ODBC on Windows Server

Post by edgore » Wed Feb 06, 2013 7:10 pm

I was just using $path as an example. There are a couple of environmental variables that are clearly related to the DB2 client, but setting those using put in the server script has not had any effect, so I have asked IBM to cinfirm what's required.

Also, just as info I am running apache and Livecode server on windows 7, and the development machine and the server machine are, in this case, the same machine. I am just running an instance of apache on my development machine.

edgore
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 197
Joined: Wed Jun 14, 2006 8:40 pm

Re: Problem with DB2 ODBC on Windows Server

Post by edgore » Fri Feb 08, 2013 9:42 pm

Yep - it was the environment variables. One I got them all set correctly within the server environment everything began to work correctly.

Since this is something that I will have to do pretty often I am just making an environment setup library script that I can include when needed.

However, since it appears that *none* of the environment variables get populated in the instance that livecode server is running in it would be useful to have the ability to specify a script that always get executed whenever the server runs, so that I could just do this once and then always have the environment the way I want it whenever the server executes, rather than having to do an include or require all the time in different scripts.

sturgis
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1682
Joined: Sat Feb 28, 2009 11:49 pm

Re: Problem with DB2 ODBC on Windows Server

Post by sturgis » Fri Feb 08, 2013 9:52 pm

not sure if there anything will apply to your problem, but here is some info about apache environment variables.

http://httpd.apache.org/docs/2.2/env.html

From a quick glance, it looks like you can add directives to your apache conf files (env and passenv) that may allow you to set things up to work without a bunch of hoop jumping.

Post Reply

Return to “CGIs and the Server”