472,121 Members | 1,604 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,121 software developers and data experts.

Obtaining parameter MAX_CONNECTIONS through the API

P
Hi,

I'm trying to acquire the parameter MAX_CONNECTIONS by using the API.
The following is the code segment I used:

struct sqlfupd paramItem[5];
paramItem[0].token = SQLF_DBTN_MAX_CONNECTIONS;
paramItem[0].ptrvalue = (char *)malloc(sizeof(int));
sqlfddb(dbName, 1, paramItem, &db2ConnArea);
printf("----------------- STAT =============== %d \n", *(int
*)paramItem[0].ptrvalue);

When I compiled that, I got the following error:

`SQLF_DBTN_MAX_CONNECTIONS' undeclared (first use in this function)

When I tried to obtain the following parameters, as per the example
found on http://webdocs.caspur.it/ibm/udb-6.1...c/d_dbcofc.htm, I
was able to do so:
SQLF_DBTN_LOCKLIST, SQLF_DBTN_BUFF_PAGE, SQLF_DBTN_MAXFILOP,
SQLF_DBTN_SOFTMAX, SQLF_DBTN_LOGPATH.

What was wrong in my attempt?

Thanks

Apr 21 '06 #1
13 2185
Hi,

It is really weird.

Have you checked the sqlutil.h file? Does "SQLF_DBTN_MAX_CONNECTIONS"
exist in this file?

BTW: It may not solve your problem but you can avoid the compilation
error by using the corresponding constant value 802 instead. Please
refer to

http://publib.boulder.ibm.com/infoce...d/r0008190.htm

regards,

tuarek

Apr 23 '06 #2
P
Hi tuarek,

Thanks for the reply. I was looking at sqlutil.h and I found the
following entries:

#define SQLF_KTN_DF_ENCRYPT_LIST 801
#define SQLF_KTN_MAX_CONNECTIONS 802

I tried googling for SQLF_KTN_MAX_CONNECTIONS but it didn't give me any
results.

I tried giving it 802 as you've suggested but it returned 0, which was
not correct.

Any idea?

Thanks

Apr 24 '06 #3
P wrote:
Hi,

I'm trying to acquire the parameter MAX_CONNECTIONS by using the API.
The following is the code segment I used:

struct sqlfupd paramItem[5];
paramItem[0].token = SQLF_DBTN_MAX_CONNECTIONS;
paramItem[0].ptrvalue = (char *)malloc(sizeof(int));
You should check here that the memory allocation was successful. Otherwise,
your program could just crash here with a segfault.
sqlfddb(dbName, 1, paramItem, &db2ConnArea);
You should use the "db2CfgGet" API that is provided since version 8:
http://publib.boulder.ibm.com/infoce...n/r0008855.htm
printf("----------------- STAT =============== %d \n", *(int
*)paramItem[0].ptrvalue);

When I compiled that, I got the following error:

`SQLF_DBTN_MAX_CONNECTIONS' undeclared (first use in this function)

When I tried to obtain the following parameters, as per the example
found on http://webdocs.caspur.it/ibm/udb-6.1...c/d_dbcofc.htm, I
was able to do so:
SQLF_DBTN_LOCKLIST, SQLF_DBTN_BUFF_PAGE, SQLF_DBTN_MAXFILOP,
SQLF_DBTN_SOFTMAX, SQLF_DBTN_LOGPATH.

What was wrong in my attempt?


You have to include "sqlutil.h" and use the constant
SQLF_KTN_MAX_CONNECTIONS. Btw, I would not recommend that you put the
explicit 802 in your source code. Better fix the real problem.

--
Knut Stolze
DB2 Information Integration Development
IBM Germany
Apr 24 '06 #4

I don't have hard evidence but since you haven't found
"SQLF_DBTN_MAX_CONNECTIONS" in your sqlutil.h file: Could there be a
version issue? I mean the db2 version you have may not be supporting
"SQLF_DBTN_MAX_CONNECTIONS" parameter?

Another try?

Logon as dbadmin to the CLP,

set max_connections through

"db2 update dbm cfg using SQLF_DBTN_MAX_CONNECTIONS 100"

or

"update dbm cfg using SQLF_DBTN_MAX_CONNECTIONS 100"

Make sure

"db2 get dbm cfg show detail " or "get dbm cfg show detail" shows your
new value in max_connections constant .

Then try your program with "802" constant. See if it returns 100.

regards,

Mehmet

Apr 24 '06 #5
P
Hi Knut,

I included "sqlutil.h" and I'm getting 0 when I used the constant
SQLF_KTN_MAX_CONNECTIONS.

What's the difference between SQLF_KTN_MAX_CONNECTIONS and
SQLF_DBTN_MAX_CONNECTIONS? I couldn't find anything about
SQLF_KTN_MAX_CONNECTIONS.

Apr 24 '06 #6
P
Hi Mehmet,

The version of DB2 I'm using is DB2 v8.1.0.64

I was unable to do
"db2 update dbm cfg using SQLF_DBTN_MAX_CONNECTIONS 100"
But I did manage to change it by doing
"db2 update dbm cfg using MAX_CONNECTIONS 100"

And when I tried to get the parameter, it was still 0. Is
SQLF_DBTN_MAX_CONNECTIONS available for 8.1?

Regards,

P

Apr 24 '06 #7
P wrote:
Hi Knut,

I included "sqlutil.h" and I'm getting 0 when I used the constant
SQLF_KTN_MAX_CONNECTIONS.

What's the difference between SQLF_KTN_MAX_CONNECTIONS and
SQLF_DBTN_MAX_CONNECTIONS? I couldn't find anything about
SQLF_KTN_MAX_CONNECTIONS.


SQLF_DBTN_MAX_CONNECTIONS doesn't exist (any more) and
SQLF_KTN_MAX_CONNECTIONS is defined in sqlutil.h.

Could you possibly provide the complete code that you're using now? Have
you switched to "db2CfgGet"?

--
Knut Stolze
DB2 Information Integration Development
IBM Germany
Apr 24 '06 #8
P
Hi Knut,

Here's the code. It's based on the example found on
http://publib.boulder.ibm.com/infoce...s-dbinfo-c.htm
db2ConnArea is the sqlca struct.

db2CfgParam cfgParameters[2]; /* to save the DB Config. */
db2Cfg cfgStruct;

/* initialize cfgStruct */
cfgStruct.numItems = 2;
cfgStruct.paramArray = cfgParameters;
cfgStruct.flags = db2CfgDatabase | db2CfgDelayed;
cfgStruct.dbname = dbName;

cfgStruct.paramArray[0].flags = 0;
cfgStruct.paramArray[0].token = SQLF_DBTN_TSM_OWNER;
cfgStruct.paramArray[0].ptrvalue = (char *)malloc(sizeof(char) * 65);
cfgStruct.paramArray[1].flags = 0;
cfgStruct.paramArray[1].token = SQLF_KTN_MAX_CONNECTIONS;
cfgStruct.paramArray[1].ptrvalue = (char *)malloc(sizeof(sqluint32));

db2CfgGet(db2Version810, (void *)&cfgStruct, &db2ConnArea);
printf(" TSM owner = %s\n", cfgParameters[0].ptrvalue);
printf(" maxconn = %u\n",
*(sqluint32 *)(cfgParameters[1].ptrvalue));

Thanks

Apr 24 '06 #9
P wrote:
Hi Knut,

Here's the code. It's based on the example found on
There are a few problems here:
db2CfgParam cfgParameters[2]; /* to save the DB Config. */
db2Cfg cfgStruct;

/* initialize cfgStruct */
cfgStruct.numItems = 2;
cfgStruct.paramArray = cfgParameters;
cfgStruct.flags = db2CfgDatabase | db2CfgDelayed;
You TSM_OWNER and MAX_CONNECTIONS are DBM CFG parameter and not DB CFG
parameter. This is the reason why you got no results.
cfgStruct.dbname = dbName;

cfgStruct.paramArray[0].flags = 0;
cfgStruct.paramArray[0].token = SQLF_DBTN_TSM_OWNER;
cfgStruct.paramArray[0].ptrvalue = (char *)malloc(sizeof(char) * 65);
cfgStruct.paramArray[1].flags = 0;
cfgStruct.paramArray[1].token = SQLF_KTN_MAX_CONNECTIONS;
cfgStruct.paramArray[1].ptrvalue = (char *)malloc(sizeof(sqluint32));
MAX_CONNECTIONS is a signed integer: http://tinyurl.com/mvwk9 If you
interpret it as unsigned, you're bound to get wrong results.
db2CfgGet(db2Version810, (void *)&cfgStruct, &db2ConnArea);
The cast to "void *" is unneccessary.
printf(" TSM owner = %s\n", cfgParameters[0].ptrvalue);
printf(" maxconn = %u\n",
*(sqluint32 *)(cfgParameters[1].ptrvalue));


Fixing the above issues should do it. Here is a working example that I
used. It also uses a variable for the result of MAX_CONNECTIONS and, thus,
avoids the ugly cast.
-----------------------------------------------------------------
#include "db2ApiDf.h"
#include <stdio.h>
#include <stdlib.h>

int main()
{
db2CfgParam cfgParameters[2]; /* to save the DB Config. */
db2Cfg cfgStruct;
sqlint32 maxConn = 0;
SQL_API_RC rc = SQL_RC_OK;
struct sqlca sqlca;

memset(&cfgParameters, 0x00, sizeof cfgParameters);
memset(&cfgStruct, 0x00, sizeof cfgStruct);
memset(&sqlca, 0x00, sizeof sqlca);

/* initialize cfgStruct */
cfgStruct.numItems = 2;
cfgStruct.paramArray = cfgParameters;
cfgStruct.flags = db2CfgDatabaseManager | db2CfgDelayed;
cfgStruct.dbname = "test";

cfgStruct.paramArray[0].flags = 0;
cfgStruct.paramArray[0].token = SQLF_DBTN_TSM_OWNER;
cfgStruct.paramArray[0].ptrvalue = (char *)malloc(sizeof(char) * 65);
cfgStruct.paramArray[1].flags = 0;
cfgStruct.paramArray[1].token = SQLF_KTN_MAX_CONNECTIONS;
cfgStruct.paramArray[1].ptrvalue = (char *)&maxConn;

if (!cfgStruct.paramArray[0].ptrvalue) {
free(cfgStruct.paramArray[0].ptrvalue);
fprintf(stderr, "Memory allocation failure.\n");
return EXIT_FAILURE;
}

rc = db2CfgGet(db2Version810, &cfgStruct, &sqlca);
if (rc != SQL_RC_OK) {
fprintf(stderr, "Could not get DB CFG. rc = %d\n", rc);
return EXIT_FAILURE;
}
else if (sqlca.sqlcode != SQL_RC_OK) {
fprintf(stderr, "Could not get DB CFG. SQLCODE = %d\n",
sqlca.sqlcode);
return EXIT_FAILURE;
}

printf(" TSM owner = %s\n", cfgParameters[0].ptrvalue);
printf(" maxconn = %d\n", (int)maxConn);
return EXIT_SUCCESS;
}
-----------------------------------------------------------------

--
Knut Stolze
DB2 Information Integration Development
IBM Germany
Apr 25 '06 #10
P
Hi Knut,

Thanks! That worked like a charm! :)

P

Apr 25 '06 #11
P
I have another question. I set MAX_CONNECTIONS back to what it was,
MAX_COORDAGENTS. I did "db2 get dbm cfg" and found out that:

MAX_COORDAGENTS = MAXAGENTS - NUM_INITAGENTS
MAXAGENTS = MAX_COORDAGENTS
NUM_INITAGENTS = 0

By executing the code above, MAX_CONNECTIONS came out to be 4294967295.

Is that correct?

Apr 26 '06 #12
P
It seems like I experience the problem when the definition of the
parameter is related to another parameter.

For example:
(CATALOGCACHE_SZ) = (MAXAPPLS*4) I'd get "catalog = 4294967295"
(PCKCACHESZ) = (MAXAPPLS*8) I'd get "pkg = 913328"

Is there any way to get around this problem?

Apr 26 '06 #13
P wrote:
I have another question. I set MAX_CONNECTIONS back to what it was,
MAX_COORDAGENTS. I did "db2 get dbm cfg" and found out that:

MAX_COORDAGENTS = MAXAGENTS - NUM_INITAGENTS
MAXAGENTS = MAX_COORDAGENTS
NUM_INITAGENTS = 0

By executing the code above, MAX_CONNECTIONS came out to be 4294967295.

Is that correct?


It can't be because the maximum signed integer is 2^31 = 2.xxx billion.
You're not considering the sign flag!

--
Knut Stolze
DB2 Information Integration Development
IBM Germany
May 2 '06 #14

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Murat Tasan | last post: by
reply views Thread by Richard Sumilang | last post: by
1 post views Thread by Jan Josefowicz | last post: by
reply views Thread by Jay donnell | last post: by
1 post views Thread by konf | last post: by
9 posts views Thread by psujkov | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.