There are a couple of things you can do outside of ADO to test that the
serveris available and listening on the desired port.
Netstat will tell you if the server is:
1. Available and online
2. Reporting that it is listening on the desired DB TCP/IP ports (i.e.,
SQL server is by default port 1433)
Telnet will tell you:
1. The server is available and online
2. Connection to the desired port is possible
Niether of these solutions will tell you that the server is bottlenecked,
experiencing long queues, in single use mode, or in a unstable state.
In your situation, I would plan worse case and code in that manner.
Make use of transactions, and minimize connectivitiy when possible.
Devise failover solutions that allow for resuming once a failed thread
restarts.
Log exceptions for later review
Request SLA from Network Support along with best times for processing
Prepare data prior to committing it
Open Connecion
store prepared data locally with a processed flag
create a transaction
commit data
complete transaction
Close connection
mark prepared data as processed
remove local cache
:Failover
Open locally cached prepared data
Open connection
create transaction
commit data
complete transaction
Close Connection
mark prepared data as processed
remove local cache
"Martin B" <ma************@gamed.com> wrote in message
news:44***********************@newsreader.inode.at ...
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 I use
System.Data.Common.DBConnection and .DBCommand.
How can I keep aware from connection losses (network not availeable,
db-server not available...)?
Are there any strategies to detect this broken connections, and how can I
implement reconnecting to the database?
The only solution I figured out, is creating a thread which frequntly
performs a SELECT 1 (MSSQL) or SELECT 1 FROM DUAL (Oracle) within a
try-catch block. When an exception occurs I have to send my other
worker-threads to sleep, till I'm able to reopen the database connection
and my Select-Statement works again. Then I have to trigger the other
threads to reopen their connections and continue working (every thread
gots his own DBConnection).
For me this seems a little bit to complicated and insecure.
It also could happen that one of the worker threads gots a timeout due
locking or delayed server responstime, and will loose his Connection in
fact of this exception. Such, or similar problems I can not get handled
with my solution.
Are there any suggestions, patterns or automathisms with ADO 2.0?
with friendly regards
Martin