Disconnect all MySQL connections

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Disconnect all MySQL connections

mailto-nik
Hi

I've got the error "cannot allocate a new connection -- maximum of 16 connections
already opened" after I tried to create a new connection to a database. However,
the reason ist, that i did not disconnect previous connections....

I don't know the name of this connections. How can I disconnect this "unknown"
connections and drivers? if I delete all objects, the error still occurs.
Exists a function which i don't know?

Thanks a lot for your help.
Regards
Nik

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Disconnect all MySQL connections

Uwe Ligges
[hidden email] wrote:

> Hi
>
> I've got the error "cannot allocate a new connection -- maximum of 16 connections
> already opened" after I tried to create a new connection to a database. However,
> the reason ist, that i did not disconnect previous connections....
>
> I don't know the name of this connections. How can I disconnect this "unknown"
> connections and drivers? if I delete all objects, the error still occurs.
> Exists a function which i don't know?
>
> Thanks a lot for your help.
> Regards
> Nik
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Which package are we talking about?

RODBC has: odbcCloseAll()
RMySQL has: dbListConnections() and dbDisconnect()

And others have other methods, just read the corresponding manuals.

Uwe Ligges

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Disconnect all MySQL connections

David James-3
In reply to this post by mailto-nik
[hidden email] wrote:
> Hi
>
> I've got the error "cannot allocate a new connection -- maximum of 16 connections
> already opened" after I tried to create a new connection to a database. However,
> the reason ist, that i did not disconnect previous connections....
>
> I don't know the name of this connections. How can I disconnect this "unknown"
> connections and drivers? if I delete all objects, the error still occurs.
> Exists a function which i don't know?

You can use dbDisconnect() together with dbListConnections() to
disconnect those connections RMySQL is managing:

   > all_cons <- dbListConnections(MySQL())
   > for(con in cons)
   +  dbDisconnect(con)

   ## check all connections have been closed
   > dbListConnections(MySQL())
   > list()

You could also kill any connection you're allowed to (not just those
managed by RMySQL):

   > dbGetQuery(con, "show processlist")
       Id      User       Host       db   Command Time
   1 2366 celnet_do gaia:47944 wireless Connect     19
   2 2367 celnet_do gaia:47946 wireless Connect     15
   3 2368 celnet_do gaia:47948 wireless   Query      0

   > dbGetQuery(con, "kill 2366")
   > dbGetQuery(con, "kill 2367")
   ....

HTH,

--
David

>
> Thanks a lot for your help.
> Regards
> Nik
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Disconnect all MySQL connections

mailto-nik
In reply to this post by Uwe Ligges
Hi

I work with RMySQL. Now, it works fine.
Thanks a lot for your prompt reply.

Have a nice and successful day
Best regards
Dominik

>-- Original-Nachricht --
>Date: Mon, 06 Mar 2006 15:35:46 +0100
>From: Uwe Ligges <[hidden email]>
>To: [hidden email]
>Cc: [hidden email]
>Subject: Re: [R] Disconnect all MySQL connections
>
>
>[hidden email] wrote:
>
>> Hi
>>
>> I've got the error "cannot allocate a new connection -- maximum of 16
connections

>> already opened" after I tried to create a new connection to a database.
>However,
>> the reason ist, that i did not disconnect previous connections....
>>
>> I don't know the name of this connections. How can I disconnect this "unknown"
>> connections and drivers? if I delete all objects, the error still occurs.
>> Exists a function which i don't know?
>>
>> Thanks a lot for your help.
>> Regards
>> Nik
>>
>> ______________________________________________
>> [hidden email] mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>
>
>Which package are we talking about?
>
>RODBC has: odbcCloseAll()
>RMySQL has: dbListConnections() and dbDisconnect()
>
>And others have other methods, just read the corresponding manuals.
>
>Uwe Ligges

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Disconnect all MySQL connections

Don MacQueen
In reply to this post by mailto-nik
Use the function

    dbListConnections()

to get a list of connections. Then use

   dbDisconnect()

to disconnect them one by one.

Using Oracle as an example:

>  dbm <- Oracle()
>  dbDisconnect(dbListConnections(dbm)[[1]])
[1] TRUE

-Don

At 3:18 PM +0100 3/6/06, [hidden email] wrote:

>Hi
>
>I've got the error "cannot allocate a new connection -- maximum of
>16 connections
>already opened" after I tried to create a new connection to a
>database. However,
>the reason ist, that i did not disconnect previous connections....
>
>I don't know the name of this connections. How can I disconnect this "unknown"
>connections and drivers? if I delete all objects, the error still occurs.
>Exists a function which i don't know?
>
>Thanks a lot for your help.
>Regards
>Nik
>
>______________________________________________
>[hidden email] mailing list
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


--
--------------------------------------
Don MacQueen
Environmental Protection Department
Lawrence Livermore National Laboratory
Livermore, CA, USA

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Loading...