[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.odbcnet

MySQL / ODBC - Closing connection

Ole-Johan Ellingsen

10/22/2002 9:22:00 AM

Hi.

I have an application (C#) using Odbc to connect to a MySQL database. I have
a class that establishes connection, does some database work, and then
closes the connection (myConn.Close()). However, the connection is still
visible in "WinMySQLAdmin.EXE". In fact, it does not disappear unless I exit
the application. The problem is that the application opens the connection,
does the work and closes several times, and eventually, I get a message
saying that there are too many connections. How can I force the connection
to close?

Best regards,
Ole-Johan Ellingsen




5 Answers

(Hussein Abuthuraya(MSFT))

10/23/2002 12:58:00 AM

0

What you are seeing is because of "Connection Pooling". With all .NET Data Providers (SqlClient, OleDb, OracleClient, ODBC), connection pooling is On by default. You
may turn it off by adding "Pooling=false" in the connection string.

Clsoing a pooled connection will return it to the pool and it will be ready for next Connection.Open call if its lifetime is not elapsed. You may read more about "Connection
Pooling" in the Framework SDK or MSDN library.

I hope this helps!


Thanks,
Hussein Abuthuraya
Microsoft Developer Support

This posting is provided "AS IS" with no warranties, and confers no rights.

Are you secure? For information about the Microsoft Strategic Technology Protection Program and to order your FREE Security Tool Kit, please visit
http://www.microsoft.co....


Ole-Johan Ellingsen

10/23/2002 9:46:00 AM

0

I have tried this connection string:
"DRIVER={MySQL ODBC 3.51
Driver};SERVER=localhost;DATABASE=mydb;USER=myuser;PASSWORD=mypass;OPTION=35
;CONNECTION LIFETIME=30;POOLING=FALSE;"
But it does not seem to make a difference. Is there something wrong in this
connection string?

Ole-Johan Ellingsen




"Hussein Abuthuraya(MSFT)" <HussAbOnline@microsoft.com> wrote in message
news:KUzeKbieCHA.1492@cpmsftngxa09...
> What you are seeing is because of "Connection Pooling". With all .NET
Data Providers (SqlClient, OleDb, OracleClient, ODBC), connection pooling is
On by default. You
> may turn it off by adding "Pooling=false" in the connection string.
>
> Clsoing a pooled connection will return it to the pool and it will be
ready for next Connection.Open call if its lifetime is not elapsed. You may
read more about "Connection
> Pooling" in the Framework SDK or MSDN library.
>
> I hope this helps!
>
>
> Thanks,
> Hussein Abuthuraya
> Microsoft Developer Support
>
> This posting is provided "AS IS" with no warranties, and confers no
rights.
>
> Are you secure? For information about the Microsoft Strategic Technology
Protection Program and to order your FREE Security Tool Kit, please visit
> http://www.microsoft.co....
>
>


(Hussein Abuthuraya(MSFT))

10/24/2002 10:44:00 PM

0

It looks like the ODBC .NET DataProvider's Connection pooling is handled by the ODBC ADMIN as indicated in the ODBC documentation. The following is an excerpt from
the ODBC.NET docs:

"When you use the ODBC .NET Data Provider, you do not need to enable connection pooling because the ODBC Driver Manager manages this automatically. For more
information about enabling and disabling connection pooling, see the Microsoft Open Database Connectivity (ODBC) documentation."



Thanks,
Hussein Abuthuraya
Microsoft Developer Support

This posting is provided "AS IS" with no warranties, and confers no rights.

Are you secure? For information about the Microsoft Strategic Technology Protection Program and to order your FREE Security Tool Kit, please visit
http://www.microsoft.co....


binarg

10/31/2002 6:16:00 AM

0

Pardon my ignorance but what all this has to do with error about "too many
connections" described in first e-mail?

Connection pooling is for re-use of connections but if you have app which
opens and closes some connection several times and receives this error, then
something is wrong with pooling mechanism...

This error should come up when you have too many apps/threads trying to open
more connections then poling mechanism have available in the same time...

Can we discus this issue further (I was just about to start some project
with eventual use of MySQL so this is very interesting for me, too).

Thanks,

binarg


"Hussein Abuthuraya(MSFT)" <HussAbOnline@microsoft.com> wrote in message
news:PtVU3Z6eCHA.648@cpmsftngxa09...
> It looks like the ODBC .NET DataProvider's Connection pooling is handled
by the ODBC ADMIN as indicated in the ODBC documentation. The following is
an excerpt from
> the ODBC.NET docs:
>
> "When you use the ODBC .NET Data Provider, you do not need to enable
connection pooling because the ODBC Driver Manager manages this
automatically. For more
> information about enabling and disabling connection pooling, see the
Microsoft Open Database Connectivity (ODBC) documentation."
>
>
>
> Thanks,
> Hussein Abuthuraya
> Microsoft Developer Support
>
> This posting is provided "AS IS" with no warranties, and confers no
rights.
>
> Are you secure? For information about the Microsoft Strategic Technology
Protection Program and to order your FREE Security Tool Kit, please visit
> http://www.microsoft.co....
>
>


Max Chernyshov

1/8/2003 9:21:00 PM

0

It looks like I am struggling with the similar issue.
ODBC connection pooling does not to be working properly,
with load testing and 50 parallel users, eventually connection pool
became full and unable to create connection exception is thrown,
once this happens the following ODBCConnection.Open calls just hang,
instead of throwing the exception.

Same behavior for the Oracle and DB2, switching to native Oracle provider
works
as expected.


"binarg" <binarg@hotmail.com> wrote in message
news:Oo$UYxJgCHA.1848@tkmsftngp10...
> Pardon my ignorance but what all this has to do with error about "too many
> connections" described in first e-mail?
>
> Connection pooling is for re-use of connections but if you have app which
> opens and closes some connection several times and receives this error,
then
> something is wrong with pooling mechanism...
>
> This error should come up when you have too many apps/threads trying to
open
> more connections then poling mechanism have available in the same time...
>
> Can we discus this issue further (I was just about to start some project
> with eventual use of MySQL so this is very interesting for me, too).
>
> Thanks,
>
> binarg
>
>
> "Hussein Abuthuraya(MSFT)" <HussAbOnline@microsoft.com> wrote in message
> news:PtVU3Z6eCHA.648@cpmsftngxa09...
> > It looks like the ODBC .NET DataProvider's Connection pooling is handled
> by the ODBC ADMIN as indicated in the ODBC documentation. The following
is
> an excerpt from
> > the ODBC.NET docs:
> >
> > "When you use the ODBC .NET Data Provider, you do not need to enable
> connection pooling because the ODBC Driver Manager manages this
> automatically. For more
> > information about enabling and disabling connection pooling, see the
> Microsoft Open Database Connectivity (ODBC) documentation."
> >
> >
> >
> > Thanks,
> > Hussein Abuthuraya
> > Microsoft Developer Support
> >
> > This posting is provided "AS IS" with no warranties, and confers no
> rights.
> >
> > Are you secure? For information about the Microsoft Strategic Technology
> Protection Program and to order your FREE Security Tool Kit, please visit
> > http://www.microsoft.co....
> >
> >
>
>