Groups | Blog | Home
all groups > dotnet odbc.net > february 2004 >

dotnet odbc.net : ODBC Connection Pooling with ADO.NET and Oracle RDB


Thomas Heder
2/27/2004 3:55:09 PM
Hi!

I believe I am not getting ODBC connection pooling in ADO.NET to work
correctly. I am connecting to an Oracle RDB database with Oracle RDB ODBC
driver 3.1.0.0.

With a test project in VB6 I start out with this call to enable pooling on
the ODBC level.

SQLSetEnvAttr(0&,SQL_ATTR_CONNECTION_POOLING,SQL_CP_ONE_PER_DRIVER,SQL_IS_IN
TEGER)

This enables connection pooling at driver level (one pool per machine), and
this is what I want, since we have quite a bit of processes active on each
machine. I do an ADO Open() and I see the DBConnection appear in RDB. When
doing Close(), the connection remains in the database for the amount of time
specified in the ODBC manager. So far so good.

Now... ADO.NET does not behave in this way. According to the documentation
though, ADO.NET "always uses pooling".

If I connect to the RDB database with OdbcConnection.Open(), I get a
connection, but when I call Close(), it immediately disappears in the
database. I see this as an indication that pooling is not working. I have
tried to call SQLSetEnvAttr() in the .NET aplication but it didn't help.
When enabling ODBC trace, I can see that ado.net magically calls
SQLSetEnvAttr with the SQL_ATTR_CONNECTION_POOLING (201) attribute, doing
some other stuff that I don't understand.

Can anyone explain this to me?

Regards!

//Thomas Heder

--------------------------------------------------------
My VB6 application gives me the following ODBC trace:


VB6 3380-32b8 ENTER SQLSetEnvAttr
SQLHENV 00000000
SQLINTEGER 201 <unknown>
SQLPOINTER [Unknown attribute 201]
SQLINTEGER -6

VB6 3380-32b8 EXIT SQLSetEnvAttr with return code 0
(SQL_SUCCESS)
SQLHENV 00000000
SQLINTEGER 201 <unknown>
SQLPOINTER [Unknown attribute 201]
SQLINTEGER -6

....and my .NET application gives me initially the same, but when the
connection is opened, it also logs this:

[....my first manual call......]

TestClient 21a0-25e8 ENTER SQLSetEnvAttr
SQLHENV 00000000
SQLINTEGER 201 <unknown>
SQLPOINTER [Unknown attribute 201]
SQLINTEGER -6

TestClient 21a0-25e8 EXIT SQLSetEnvAttr with return code 0
(SQL_SUCCESS)
SQLHENV 00000000
SQLINTEGER 201 <unknown>
SQLPOINTER [Unknown attribute 201]
SQLINTEGER -6

[.....other stuff.....]

[......ado.net calls sqlsetenvattr again.................]

TestClient 21a0-25e8 ENTER SQLSetEnvAttr
SQLHENV 08061540
SQLINTEGER 201 <unknown>
SQLPOINTER [Unknown attribute 201]
SQLINTEGER -6

TestClient 21a0-25e8 EXIT SQLSetEnvAttr with return code 0
(SQL_SUCCESS)
SQLHENV 08061540
SQLINTEGER 201 <unknown>
SQLPOINTER [Unknown attribute 201]
SQLINTEGER -6


Thomas Heder
2/28/2004 12:12:40 AM
Ok... I have solved a part of this... I had failed to actually enable
pooling on the connection. The column "Pool Timeout" in the ODBC Manager was
hidden, and the way of doubleclicking the drivername to setup pooling is
anything but intuitive, but now I at least get pooling to work.

Another question: Now it seems like every client gets its own pool. Is it
possible to override this and place the driver in "one pool per driver" mode
even under ado.net?

//Thomas




[quoted text, click to view]

AddThis Social Bookmark Button