473,407 Members | 2,312 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 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 2273
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Murat Tasan | last post by:
i have a quick question... is there a way to obtain the reference to the object which called the currently executing method? here is the scenario, i have a class and a field which i would like to...
0
by: Richard Sumilang | last post by:
Where do I go to set the max_connections settings so I can have over 100? -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: ...
1
by: Jan Josefowicz | last post by:
Hi, I'm trying to change the value of max_connections variable but mysqld doesn't accept that. I use mysql 3.23.54 and my config file /etc/my.cnf looks like: .... .... set-variable...
2
by: Sami | last post by:
I keep getting the famous 'Too Many Connection' Error, and don't know how to change my variables, so they persist even if i have to restart mysql service. Platform: Windows 2003 Server My...
0
by: Jay donnell | last post by:
Hi all, I can't seem to change my max_connections variable in mysql. If I try to do it through the client I get this. mysql> set global max_connections=500; ERROR 1064: You have an error in...
1
by: konf | last post by:
Hallo, I am using PostgreSQL 7.4 on UltraSparc machine and I have a touble with max_connections param. I must set only max_connections to 8, when I set more, I got error for shared memory. ...
9
by: psujkov | last post by:
Hi everybody, int f(int a, int b) { return a + b; }; is it possible to obtain this function signature - int (int, int) in this case - for use in boost::function_traits ? e.g. std::cout << "f's...
7
by: bouy78 | last post by:
Quick Question Seems to be an easy task, but apparently I'm not very bright. I have an array of checkboxes, created at runtime and inserted in a panel. Upon creation, they're each attached to...
1
by: dmitrey | last post by:
hi all, howto check is function capable of obtaining **kwargs? i.e. I have some funcs like def myfunc(a,b,c,...):... some like def myfunc(a,b,c,...,*args):... some like
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.