Hello,
I am trying to port an exising product to support DB v9.
This is a piece of code similar to the one in the product
if(DB2SetCLPEnv_api (GetCurrentProcessId()) == 0)
{
char buff[2048];
FILE *fp = NULL;
runCmd = L"\"C:\\Program Files\\IBM\\SQLLIB\\BIN\\DB2\" connect to MYDB user db2admin using \'db2admin\'";
if ( (fp = _popen(runCmd.c_str(), "rt")) != NULL)
{
while (fgetts(buff, 2048, fp) != NULL )
{
printf(L"%s",buff);
}
}
else
{
printf("Unable to execute command \n");
}
runCmd = L"\"C:\\Program Files\\IBM\\SQLLIB\\BIN\\DB2\" select grantee, granteetype, grantor from syscat.dbauth where bindaddauth = \'Y\'";
if((fp = _wpopen(runCmd.c_str(), L"rt")) != NULL)
{
while (fgetts(buff, 2048, fp) != NULL )
{
printf(L"%s",buff);
}
}
else
{
printf(L"Unable to execute command \n");
}
}
else
{
printf("Unable to set DB2 CLP \n");
}
Basically what i am try to do is to call DB2SetCLPEnv_api and execute two commands using _popen. The _popen function creates a pipe and asynchronously executes a spawned copy of the command processor with the specified string command. The first command connects to MYDB using the username and password provided. The second command executes a select query.
In v8 the connection establised using the command
DB2 connect to MYDB user db2admin using 'db2admin'
seems to persist until a
DB2 connect reset
is called and the select query executes correctly.
in v9 the connection establised using the command
DB2 connect to MYDB user db2admin using 'db2admin'
gets terminated immediately and when i try to execute the second command i get an error that says
SQL1024N A database connection does not exist. SQLSTATE=08003
The above mentioned code is being built on different platforms including most flavours of windows and Linux. A major code change would require significant development and testing effort. Can anyone provide me with a solution to fix this.
Thnaks and Regards
myDB2Queries