By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,333 Members | 1,226 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,333 IT Pros & Developers. It's quick & easy.

"SQL1024N A database connection does not exist" when using db2GetSnapshotSizeData and db2gGetSnapshot

P: n/a
Hi all,

I wrote an application that takes snapshots using the snapshot monitor
API (db2gGetSnapshot and db2GetSnapshotSize), every now and then these
methods fail and I get SQL1024N error (A database connection does not
exist. SQLSTATE=08003).
The application is attached to the db2 instance initialization, and to
be on the safe side, I also made sure that the DB2INSTANCE environment
variable is also set.

Does anybody familiar with this problem?

TIA
Yaron

Feb 22 '06 #1
Share this Question
Share on Google+
10 Replies


P: n/a
Yaron,
An indicator iStoreResult which belongs to structure
db2gGetSnapshotData which in turn controls the behaviour the
db2GetSnapshot API enforces the manager to store the results of the
call in the db2 server if enabled.
You might want to check if the mentioned indicator isn't enabled.

I wrote an application that takes snapshots using the snapshot monitor
API (db2gGetSnapshot and db2GetSnapshotSize), every now and then these
methods fail and I get SQL1024N error (A database connection does not
exist. SQLSTATE=08003).
The application is attached to the db2 instance initialization, and to
be on the safe side, I also made sure that the DB2INSTANCE environment
variable is also set.

Does anybody familiar with this problem?

TIA
Yaron


Feb 22 '06 #2

P: n/a
Hi Shyam.

The flag is always set to 0, but it still happends.

Any other ideas ?

Feb 23 '06 #3

P: n/a
Udo
There's a sample called "utilsnap.c" in the sqllib/samples/c"
directory. I suggest to start with this sample.

Regards,
Udo

--
Speedgain for DB2 - The DB2 Monitor
http://www.itgain.de/en/index.html

Feb 23 '06 #4

P: n/a
Hi Udo.
I used this sample to write the application.
The snapshot takes snapshots in a loop, but in some cases (same
source, even the same process) one of the above functions fails with
the specified error message.

Feb 23 '06 #5

P: n/a
Yaron,
For the convenience sake would you be able to post the code which you
have written so that we could get a chance to review it.
Without which we would be guessing!

Hi Udo.
I used this sample to write the application.
The snapshot takes snapshots in a loop, but in some cases (same
source, even the same process) one of the above functions fails with
the specified error message.


Feb 23 '06 #6

P: n/a
sure.
snapshotParam is a valid application id and snapshotType is
SQLMA_DBASE_ALL or SQLMA_APPL

<code>

struct sqlma *sqlma;
sqlma = (struct sqlma *) malloc(SQLMASIZE(1));
struct db2gGetSnapshotData sanpshotData;
struct sqlm_collected collected;
struct sqlca sqlca;
sqluint32 buffer_sz;
db2GetSnapshotSizeData getSnapshotSizeParam;
sqluint32 outputFormat;
memset(sqlma,'\0',SQLMASIZE(1));
sqlma->obj_num = 1;
sqlma->obj_var[0].obj_type = snapshotType;
if (snapshotParam != NULL)
{
strcpy(sqlma->obj_var[0].object,snapshotParam);
}

memset(&getSnapshotSizeParam,0,sizeof(getSnapshotS izeParam));
getSnapshotSizeParam.piSqlmaData = sqlma;
getSnapshotSizeParam.iVersion = SQLM_CURRENT_VERSION;
getSnapshotSizeParam.iNodeNumber = SQLM_ALL_NODES;
getSnapshotSizeParam.iSnapshotClass = SQLM_CLASS_DEFAULT;
getSnapshotSizeParam.poBufferSize = &buffer_sz;
db2GetSnapshotSize(db2Version810, &getSnapshotSizeParam, &sqlca);
if(sqlca.sqlcode !=0)
{
free(sqlma);
sqlma = NULL;
Db2Utilities::throwSqlExceptionOnError(sqlca);
}
if (buffer_sz >0 )
{
memset(&collected, 0, sizeof(struct sqlm_collected));
memset(&sanpshotData,0,sizeof(db2gGetSnapshotData) );

buffer = (char*)malloc(buffer_sz);
sanpshotData.piSqlmaData = sqlma;
sanpshotData.iNodeNumber = SQLM_ALL_NODES;
sanpshotData.iBufferSize = buffer_sz;
sanpshotData.iVersion = SQLM_CURRENT_VERSION;
sanpshotData.iSnapshotClass = SQLM_CLASS_DEFAULT;
sanpshotData.poCollectedData = &collected;
sanpshotData.poBuffer = buffer;
sanpshotData.iStoreResult = 0;
sanpshotData.poOutputFormat = &outputFormat;

db2GetSnapshot(db2Version810,&sanpshotData,&sqlca) ;
free(sqlma);
sqlma = NULL;
if (sqlca.sqlcode != cEmptySnapshotSqlcode && sqlca.sqlcode !=0)
{
Db2Utilities::throwSqlExceptionOnError(sqlca);
}
</code>

Feb 23 '06 #7

P: n/a
In article <11**********************@g47g2000cwa.googlegroups .com>,
(st*******@gmail.com) says...
Hi all,

I wrote an application that takes snapshots using the snapshot monitor
API (db2gGetSnapshot and db2GetSnapshotSize), every now and then these
methods fail and I get SQL1024N error (A database connection does not
exist. SQLSTATE=08003).
The application is attached to the db2 instance initialization, and to
be on the safe side, I also made sure that the DB2INSTANCE environment
variable is also set.

Does anybody familiar with this problem?

TIA
Yaron


Maybe the instance has been stopped while running the snapshots?
Feb 23 '06 #8

P: n/a
nope.
it's always up (there is another sessions that work with this database
instance, and they work fine).

Feb 24 '06 #9

P: n/a
It seems that the snapshot library is not thread safe, once I
synchronized the invocations to the snapshot API the problem was solved.

Feb 27 '06 #10

P: n/a
Udo
If you use the API's in a multithreaded environment you have to follow
IBM's rules:

How to use multiple context APIs on UNIX
http://publib.boulder.ibm.com/infoce.../v8//index.jsp

Regards,
Udo

--
Speedgain for DB2 - The DB2 Monitor
http://www.itgain.de/en/index.html

Feb 27 '06 #11

This discussion thread is closed

Replies have been disabled for this discussion.