473,394 Members | 1,840 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,394 software developers and data experts.

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 3806
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: lawrence | last post by:
I posted before, but have now narrowed my problem down to this method. At the start of the method, I test to make sure that I have a resource, a pointer to data returned from a database. This test...
3
by: Mudge | last post by:
Hi, My hosting provider only allows me to use 50 connections to my MySQL database that my Web site will use. I don't know what this 50 connections means exactly. Does this mean that only 50...
6
by: Rasool | last post by:
Hi, We have an asp.net application that we constanly use to query some data from two servers (one prod and the other test). Everytime we have to go to web.config and change the connection string...
14
by: Nick Gilbert | last post by:
Hi, I have an asp.net application which runs from a CD-ROM using Cassini. As such, it is single user only. The application connects to an Access database when it is loaded, and keeps the same...
4
by: WebBuilder451 | last post by:
I have a project that i built using vs.net. The database connections were created using drag and drop. Rather than deleting the connections and re-creating the connections to the production server...
3
by: Martin B | last post by:
Hallo! I'm working with C# .NET 2.0, implementing Client/Server Applications which are connecting via Network to SQL-Server or Oracle Databases. To stay independent from the underlaying Database...
35
by: Terry Jolly | last post by:
Web Solution Goal: Have a global database connection Why: (There will be 30+ tables, represented by 30+ classes) I only want to reference the database connection once. I put the connection...
1
by: Jac | last post by:
Hey, How can I test if there is an connection-exception when using database application block from the enterprise service? I stopped the sqlserver. I do now the following : Database db =...
2
by: samadams_2006 | last post by:
Hello, I have a problem that I'm hoping someone will be able to help me resolve. 1) I have a C# Web Site in which I connect to the database: "Install Microsoft SQL Server 2005 Express...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...
0
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...

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.