473,549 Members | 2,260 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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_C ONNECTIONS;
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_LOCKL IST, SQLF_DBTN_BUFF_ PAGE, SQLF_DBTN_MAXFI LOP,
SQLF_DBTN_SOFTM AX, SQLF_DBTN_LOGPA TH.

What was wrong in my attempt?

Thanks

Apr 21 '06 #1
13 2286
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_ENC RYPT_LIST 801
#define SQLF_KTN_MAX_CO NNECTIONS 802

I tried googling for SQLF_KTN_MAX_CO NNECTIONS 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_C ONNECTIONS;
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_LOCKL IST, SQLF_DBTN_BUFF_ PAGE, SQLF_DBTN_MAXFI LOP,
SQLF_DBTN_SOFTM AX, SQLF_DBTN_LOGPA TH.

What was wrong in my attempt?


You have to include "sqlutil.h" and use the constant
SQLF_KTN_MAX_CO NNECTIONS. 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_C ONNECTIONS 100"

or

"update dbm cfg using SQLF_DBTN_MAX_C ONNECTIONS 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_CO NNECTIONS.

What's the difference between SQLF_KTN_MAX_CO NNECTIONS and
SQLF_DBTN_MAX_C ONNECTIONS? I couldn't find anything about
SQLF_KTN_MAX_CO NNECTIONS.

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_C ONNECTIONS 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_C ONNECTIONS 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_CO NNECTIONS.

What's the difference between SQLF_KTN_MAX_CO NNECTIONS and
SQLF_DBTN_MAX_C ONNECTIONS? I couldn't find anything about
SQLF_KTN_MAX_CO NNECTIONS.


SQLF_DBTN_MAX_C ONNECTIONS doesn't exist (any more) and
SQLF_KTN_MAX_CO NNECTIONS 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.numIt ems = 2;
cfgStruct.param Array = cfgParameters;
cfgStruct.flags = db2CfgDatabase | db2CfgDelayed;
cfgStruct.dbnam e = dbName;

cfgStruct.param Array[0].flags = 0;
cfgStruct.param Array[0].token = SQLF_DBTN_TSM_O WNER;
cfgStruct.param Array[0].ptrvalue = (char *)malloc(sizeof (char) * 65);
cfgStruct.param Array[1].flags = 0;
cfgStruct.param Array[1].token = SQLF_KTN_MAX_CO NNECTIONS;
cfgStruct.param Array[1].ptrvalue = (char *)malloc(sizeof (sqluint32));

db2CfgGet(db2Ve rsion810, (void *)&cfgStruct, &db2ConnArea );
printf(" TSM owner = %s\n", cfgParameters[0].ptrvalue);
printf(" maxconn = %u\n",
*(sqluint32 *)(cfgParameter s[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.numIt ems = 2;
cfgStruct.param Array = 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.dbnam e = dbName;

cfgStruct.param Array[0].flags = 0;
cfgStruct.param Array[0].token = SQLF_DBTN_TSM_O WNER;
cfgStruct.param Array[0].ptrvalue = (char *)malloc(sizeof (char) * 65);
cfgStruct.param Array[1].flags = 0;
cfgStruct.param Array[1].token = SQLF_KTN_MAX_CO NNECTIONS;
cfgStruct.param Array[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(db2Ve rsion810, (void *)&cfgStruct, &db2ConnArea );
The cast to "void *" is unneccessary.
printf(" TSM owner = %s\n", cfgParameters[0].ptrvalue);
printf(" maxconn = %u\n",
*(sqluint32 *)(cfgParameter s[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(&cfgPara meters, 0x00, sizeof cfgParameters);
memset(&cfgStru ct, 0x00, sizeof cfgStruct);
memset(&sqlca, 0x00, sizeof sqlca);

/* initialize cfgStruct */
cfgStruct.numIt ems = 2;
cfgStruct.param Array = cfgParameters;
cfgStruct.flags = db2CfgDatabaseM anager | db2CfgDelayed;
cfgStruct.dbnam e = "test";

cfgStruct.param Array[0].flags = 0;
cfgStruct.param Array[0].token = SQLF_DBTN_TSM_O WNER;
cfgStruct.param Array[0].ptrvalue = (char *)malloc(sizeof (char) * 65);
cfgStruct.param Array[1].flags = 0;
cfgStruct.param Array[1].token = SQLF_KTN_MAX_CO NNECTIONS;
cfgStruct.param Array[1].ptrvalue = (char *)&maxConn;

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

rc = db2CfgGet(db2Ve rsion810, &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

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
9621
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 populate with a reference to the object that constructed this current object. i would attempt to accomplish this by setting the appropriate field...
0
1618
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: http://lists.mysql.com/mysql?unsub=mysql@freebsd.csie.nctu.edu.tw
1
5794
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 max_connections=200
2
23804
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 Program is a WebApplication that is written in VB.Net Using ODBC and OLEDB to connect <- (don't blame me, i just took this over) From what i have read...
0
4478
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 your SQL syntax near 'max_connections=500' at line 1 Then put set-variable = max_connections=300
1
2273
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. Most connection is from J2EE application server and here is no problem, I am using connection pooling and I have defined maximum connections for each...
9
682
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 arity : " << boost::function_traits<*obtaining signature from f()*>::arity << std::endl; please no macro solutions - only C++ (Boost MPL maybe could...
7
1916
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 the same CheckChanged event. Within this event, how do I know the index of the checkbox that triggered it? Thanks in advance.
1
1586
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
7546
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7471
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7740
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7985
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7503
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7830
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6071
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5387
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
1
1082
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.