[R] Disconnect all MySQL connections
dj at research.bell-labs.com
Mon Mar 6 15:52:02 CET 2006
mailto-nik at bluemail.ch wrote:
> 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)
## check all connections have been closed
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")
> Thanks a lot for your help.
> R-help at stat.math.ethz.ch mailing list
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
More information about the R-help