Connection Pool - Does not check for Server Status.

  • Thread starter Thread starter HiChetu
  • Start date Start date
H

HiChetu

hi All,

Connection Pool - Does not check for Server Status.

Here is the scenario :

1) SQL Server is up
2) Create a connection pool for a particular connection string by
repeatedly executing the same query in .NET ( using SqlConnection and
SqlCommand classes )
This involves following steps
- Open a connection
- Execute a Query
- Close the connection


3) STOP the SQL Server.

4) Run the same query again.
We notice that
- Opening a Connection goes through fine. If the pool was not
formed ( if we are opening the connection for the first time ), this
would have FAILED by throwing SQL Server not found execption.
- Execute Query , Throws an Exception - General Network Error,
Error Number 11.


5) Now RE-START the SQL Server.

6) Run the same query again.
We notice that
- Opening a Connection goes through fine.
BUT, - Execute Query , Throws an Exception - General Network
Error, Error Number 11.
An Exception is thrown even if SQL Server is UP!


Once the Server is up, we want the connection to succeed.

Now, How do we handle this scenario?

How do we invalidate the Connection Pool?


thanks,
HiChetu
 
Hi,

This is as designed.
Open just gets available (already open) connection from pool or creates a
new one.
When the communication error occurs (such as in ExecuteXXX) the connection
is removed from the pool.
One of the scenarios would be:
When you encounter the database communication related error, try to create a
new connection with same connection string plus a whitespace at the end and
repeat the process.
This will force new connection creation.
 
Back
Top