470,591 Members | 1,484 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,591 developers. It's quick & easy.

Test database connection using C++

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
2 3726
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
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.

Similar topics

3 posts views Thread by Mudge | last post: by
4 posts views Thread by WebBuilder451 | last post: by
3 posts views Thread by Martin B | last post: by
35 posts views Thread by Terry Jolly | last post: by
1 post views Thread by Jac | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.