473,403 Members | 2,338 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,403 software developers and data experts.

Strange question on .NET and Oracle connection

Hello All,

I am trying to redirect users to a standby webpage in case our application
is down due to database server failure. To facilitate this I am opening a
test connection within a try/catch block in application_beginrequest event of
global.asax and in case the connection could not be established, I am
redirecting the users in the catch block.

Now to the interesting part. I am in the testing phase of this feature.
Since our production and development database server are the same I am using
a different approach to test this. I am running the application from my local
machine's web server and I am unplugging the network jack to simulate the
database server failure which is located at some other place.

So, once I unplug the network jack, the very first request should be
redirected to standy page because techinically the connection to Oracle
should not be established. But surprisingly this request is able to make a
database connection even though there is no network connectivity. When I
tried to debug and see, the execution was going well past the
OracleConnection.open() successfully and not going into the catch loop. But
the next request following this request is going into the catch block and is
redirected. What is the reason behind this strange behavior. Does .NET cache
the OracleConnections?

Here is the code....

System.Data.OracleClient.OracleConnection myDBConn =
new System.Data.OracleClient.OracleConnection();
try
{
myDBConn.ConnectionString =
System.Configuration.ConfigurationSettings.AppSett ings["ConnectionString"];
myDBConn.Open();

}
catch(OracleException ex)
{
//Database server is down; Redirect to standby page
}
Thanks a lot!!!
Nov 19 '05 #1
2 1480
I am not sure where the issue is, but I would consider using the global Error
handler instead of setting up a try ... catch. This way all errors can be
redirected by your redirect and you can send the SQL specific exception to a
particular page.

You can also declaratively set up an error redirect in web.config, but this
will not allow you to weed out SQL connection issues.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

***************************
Think Outside the Box!
***************************
"Diffident" wrote:
Hello All,

I am trying to redirect users to a standby webpage in case our application
is down due to database server failure. To facilitate this I am opening a
test connection within a try/catch block in application_beginrequest event of
global.asax and in case the connection could not be established, I am
redirecting the users in the catch block.

Now to the interesting part. I am in the testing phase of this feature.
Since our production and development database server are the same I am using
a different approach to test this. I am running the application from my local
machine's web server and I am unplugging the network jack to simulate the
database server failure which is located at some other place.

So, once I unplug the network jack, the very first request should be
redirected to standy page because techinically the connection to Oracle
should not be established. But surprisingly this request is able to make a
database connection even though there is no network connectivity. When I
tried to debug and see, the execution was going well past the
OracleConnection.open() successfully and not going into the catch loop. But
the next request following this request is going into the catch block and is
redirected. What is the reason behind this strange behavior. Does .NET cache
the OracleConnections?

Here is the code....

System.Data.OracleClient.OracleConnection myDBConn =
new System.Data.OracleClient.OracleConnection();
try
{
myDBConn.ConnectionString =
System.Configuration.ConfigurationSettings.AppSett ings["ConnectionString"];
myDBConn.Open();

}
catch(OracleException ex)
{
//Database server is down; Redirect to standby page
}
Thanks a lot!!!

Nov 19 '05 #2
On Fri, 8 Jul 2005 08:29:04 -0700, Diffident <Di*******@discussions.microsoft.com> wrote:

¤ Hello All,
¤
¤ I am trying to redirect users to a standby webpage in case our application
¤ is down due to database server failure. To facilitate this I am opening a
¤ test connection within a try/catch block in application_beginrequest event of
¤ global.asax and in case the connection could not be established, I am
¤ redirecting the users in the catch block.
¤
¤ Now to the interesting part. I am in the testing phase of this feature.
¤ Since our production and development database server are the same I am using
¤ a different approach to test this. I am running the application from my local
¤ machine's web server and I am unplugging the network jack to simulate the
¤ database server failure which is located at some other place.
¤
¤ So, once I unplug the network jack, the very first request should be
¤ redirected to standy page because techinically the connection to Oracle
¤ should not be established. But surprisingly this request is able to make a
¤ database connection even though there is no network connectivity. When I
¤ tried to debug and see, the execution was going well past the
¤ OracleConnection.open() successfully and not going into the catch loop. But
¤ the next request following this request is going into the catch block and is
¤ redirected. What is the reason behind this strange behavior. Does .NET cache
¤ the OracleConnections?
¤
¤ Here is the code....
¤
¤ System.Data.OracleClient.OracleConnection myDBConn =
¤ new System.Data.OracleClient.OracleConnection();
¤ try
¤ {
¤ myDBConn.ConnectionString =
¤ System.Configuration.ConfigurationSettings.AppSett ings["ConnectionString"];
¤ myDBConn.Open();
¤
¤ }
¤ catch(OracleException ex)
¤ {
¤ //Database server is down; Redirect to standby page
¤ }
¤

When you open a connection there is a request to the connection pool before attempting to open a new
connection. My guess is that your open statement is using an existing connection from the pool.

You will probably need to do a bit more work in order to determine whether that connection can still
talk to the database.
Paul
~~~~
Microsoft MVP (Visual Basic)
Nov 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Harry | last post by:
Using Oracle 8i enterprise on win 2000 (sp3) Installed the standard configuration & whenever I make a connection it takes about 10 secs. It's running on a P1900 with 1gb Ram so no reason there...
2
by: Demetris | last post by:
Hello there. I have ORACLE 8.1.7.4 server on AIX 5.1. I have another server (BIZTALK) with Oracle client 8.1.7. The system is running ok. I can connect from the client on my database server just...
5
by: SerGioGio | last post by:
Hello, I am going nuts. I am trying to connect to my local ORACLE instance using ODBC. It used to work few weeks ago, but it fails now. Connection with: - SQL*plus: connection works! -...
1
by: Cliff Cooley | last post by:
Can anybody suggest what may be causing the following problem ? I have an ASP script that opens a connection to an Oracle database using a DSN connection string, such as : Set dbConn=...
9
by: mcbill20 | last post by:
Hello all. I just installed Oracle 10g developer tools on a machine running XP Pro and Office XP. Before this I had just the Oracle 9 client installed. I the previous configuration, I was able to...
0
by: ʹÃûÑï | last post by:
ORA-03114: not connected to ORACLE && MS's Bug?? DataBase:Oracle 817 using OracleClient,net framework 1.1 I'm using ADO.Net in C# with Oracle 817. and following is my public data access...
0
by: Anonymous User | last post by:
Hi, I am working on a mobile application that consists of a number of handheld scanners, an Xml Web service and an Oracle 9i database in a highly secure environment. The .Net Compact Framework...
7
by: =?Utf-8?B?QVRT?= | last post by:
HOWTO Run multiple SQL statements from ASP/ADO to an Oracle 10g. Please help, I'm trying to write an ASP page to use ADO to run a long query against an Oracle 10g database, to create tables,...
17
by: kanishka1213 | last post by:
when i run perl script in the cmd prompt , it runs well and outputs results from db. but when i run the same script on apache server internet explorer. i get an error as -----...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.