Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Database timeout too slow

Reply
Thread Tools

Database timeout too slow

 
 
Kevin Blount
Guest
Posts: n/a
 
      07-26-2006
I have a site that uses a connection to an Oracle server, and I'm
looking to make it intelligent enough so that if the database is
offline for any reason (IT are updating, etc) then my site won't break.

This is easy enough with a try/catch around my conn.Open(); command,
but the time it takes for the catch to kick in is huge, relatively
speaking. For example, I have one page that makes 2 seperate calls to
my method to return a DataTable, and each one takes about 20 seconds to
time out, meaning that the page takes about 40 seconds to finally load.
It's possible that each page could make two connections, so every page
would take this long, making the site un-navigable.

I was wondering if anyone might know a technique for checking more
quickly if a connection to the database is possible. I had looked at
adding "Connection Timeout=1" to my connection string, but I found this
this essentially skips the connection all together.

My setup is that I use a VPN to connect to a remote Oracle database,
alow my scripts to run locally but using data from this remote source.
If I disconnect from the VPN and run my scripts, the VPN asks to get
connected, essentially letting me know that an attempt to get the data
is being made. If I cancel the VPN dialog (or close it entirely) that's
when I have to wait 20 per conn.Open(); If I add "Connection
Timeout=1;" to my connection string, I get no VPN dialog, so no attempt
it being made, and even when the VPN *is* connected, my scripts don't
return a DataTable.

So, other than my failed attempt at fixing this, are there any quicker
techniques for checking the connection to the database, or for
returning a Timeout or other error sooner? I'm not against Oracle
config changes, though I don't have permissions to our DB, so this
would need to be approved by my IT dept first, and thus isn't as
disirable.

here's my method for returning the DataTable, in case it helps:

public static DataTable selectQuery(string sSQLQuery, string
sDBUsername, string sDBPassword)
DataSet oDS = new DataSet();
DataTable oDT = new DataTable();
OracleDataAdapter oDA = new OracleDataAdapter();

string sConnectString = "Data Source="+sDBServerName+";User
Id="+sDBUsername+";Password="+sDBPassword+";";
OracleConnection oConn = new OracleConnection(sConnectString);

try
{
oConn.Open();
oDA.SelectCommand = new OracleCommand(sSQLQuery, oConn);
oDA.Fill(oDS, "myTable");
oDT = oDS.Tables["myTable"];

oDA.Dispose();
oDS.Dispose();
oConn.Close();
oConn.Dispose();

return oDT;
}
catch (Exception err)
{
oDA.Dispose();
oDS.Dispose();
oConn.Close();
oConn.Dispose();
... code to log the error ...
//return empty DataTable
return oDT;
}

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Database Database Database Database scott93727@gmail.com Computer Information 0 09-27-2012 02:43 AM
DataBase DataBase DataBase DataBase scott93727@gmail.com Computer Information 0 09-26-2012 09:40 AM
Re: slow slow slow! Expert lino fitter Computer Support 0 12-10-2008 02:33 PM
Timeout::timeout and Socket timeout Mark Probert Ruby 1 10-06-2004 09:30 AM
Problems with imaging (too slow or too much RAM) SB Java 0 08-05-2003 11:06 AM



Advertisments