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

Test database connection using C++

P: n/a
Hello,

DB2 V7 FP14 running Linux.

Our application constantly tests whether the database connection is
still alive before sending new statements to the DB. A "values current
timestamp" statement is issued and, if there is no database exception,
the connection acquired is considered to be alive.

During one of my event monitors, this statement was by far the most
executed in the DB.

I personally dislike this solution. Just wondering if there is any
simpler solution / API for this. We are using C++.

TIA, Michel.

Feb 24 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Michel Esber wrote:
Hello,

DB2 V7 FP14 running Linux.

Our application constantly tests whether the database connection is
still alive before sending new statements to the DB. A "values current
timestamp" statement is issued and, if there is no database exception,
the connection acquired is considered to be alive.


How about simply sending the intended SQL statement and then handling the
error afterwards if there is one?

The pinging is equally unreliable as the connection might break down between
the ping and the actual start of the execution of the SQL statement. So
even then you have to handle a broken connection as part of the usual error
handling.

--
Knut Stolze
DB2 Information Integration Development
IBM Germany
Feb 24 '06 #2

P: n/a
Michel,
You might want to look at the db2gDatabasePing API whose prerequisite
is connection.
For futher information
http://publib.boulder.ibm.com/infoce...n/r0001915.htm
Hello,

DB2 V7 FP14 running Linux.

Our application constantly tests whether the database connection is
still alive before sending new statements to the DB. A "values current
timestamp" statement is issued and, if there is no database exception,
the connection acquired is considered to be alive.

During one of my event monitors, this statement was by far the most
executed in the DB.

I personally dislike this solution. Just wondering if there is any
simpler solution / API for this. We are using C++.

TIA, Michel.


Feb 27 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.