changing connection properties after opening when pooling is enabled

  • Thread starter Plausible Indirection
  • Start date
P

Plausible Indirection

I've been working from the assumption that all connections within a
pool should behave the same, but I'm wondering how that is possible if
some properties of the connection can be set from both the connection
string and from a property. For an example with minor effect, let's
consider PacketSize or "Packet Size".

Pooling works by making collections (pools) of connections with
identical connection strings. What if you set PacketSize and "Packet
Size" and for some connection set PacketSize to something different
from "Packet Size" after setting the connection string? Won't your
connection behave differently from others in the same pool? That
would be OK until that connection was closed at the application level,
but it could cause problems when the 'physical' connection is reused
by another public-level connection object.

I would speculate that this could be a reason why exact connection
strings are used to determine the pool into which a connection is
placed or from which it is drawn. I would guess that the implementors
of the connection pool used some form of IDictionary collection, like
maybe a Hashtable, and these collections don't like to have their key
values change. Properties can change, but the connection string as it
was when the connection is opened can provide a unique snapshot value.

The only safe way out of this that I can think of is to have the pool
manager reset all the properties of a connection to the default when
it is closed and to re-parse the connection string to re-establish the
user settings.

I'm thinking this could have performance implications for how an app
manages connection settings if something less trivial were involved,
like the database setting.

Does this make sense? Have I gone astray in this logic?

-Chris
 
P

Patrice

IMO you can't change these properties once the connection is open. Actually
I just gave this a quick look and it looks like it's read only.

Patrice
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top