Last post Apr 13, 2015 06:20 PM by Lannie
Apr 13, 2015 02:50 PM|NoBullMan|LINK
I am trying to test a web service that uses Oracle 11g database. I have added OrcaleException catch blocks in DAL which will supposedly write to Windows event log and need to test it to make sure it works but have no idea how to simulate either a connection
or a command timeout. Any help or hints is appreciated.
public override string GetSomething(string sParam1, string sParam2)
OracleConnection conn = new OracleConnection(this.DSSConnectionString);
OracleCommand oraCmd = new OracleCommand();
string sRet = string.Empty;
string sQuery = "select Something from someTable";
oraCmd.BindByName = true;
SetOraCommandType(oraCmd, CommandType.Text, sQuery);
oraCmd.Connection = conn;
OracleDataReader oraReader = oraCmd.ExecuteReader();
if (oraReader["Something"] != DBNull.Value)
sRet = oraReader["Something"].ToString();
catch (Exception ex)
catch (OracleException oex)
if (oraCmd != null)
if (conn != null)
Apr 13, 2015 03:44 PM|Lannie|LINK
just doing OPEN and CLOSE command with Oracle Exception handling using the connection information works for me on hey.. DB are you there today before I start my application?
and of course if you are logging to the server event log, you might need some permissions in place for the application to do that.
Apr 13, 2015 03:57 PM|NoBullMan|LINK
I tried setting "Connection Timeout" to 1 in the connection string (in web.config) but it doesn't timeout. CommandTimeout seems to be read-only and cannot be set.
Can you provide a sample if you have something that simulates either timeouts?
Apr 13, 2015 06:20 PM|Lannie|LINK
I believe that timeout setting works for ODP.NET TRANSACTIONS.
Start a transaction and the clock starts ticking.