[R] Fwd: Cannot allocate a new database connection error
Uwe Ligges
ligges at statistik.tu-dortmund.de
Sat May 16 16:21:08 CEST 2009
Open a connection as in
con <- myDbConnect(dbName,hostName)
before the loop starts and afterwards just work on "con".
Uwe Ligges
Moumita Das wrote:
> ---------- Forwarded message ----------
> From: Moumita Das <das.moumita.online at gmail.com>
> Date: Sat, May 16, 2009 at 2:26 PM
> Subject: Cannot allocate a new database connection error
> To: r-help-request at r-project.org
>
>
> Hi friends,
> why do i keep getting this error?The program runs, twice and every third
> time i get this error.I have to quit.Again get teh R-prompt and then run the
> script.
>
> *Error in mysqlNewConnection(drv, ...) :
> RS-DBI driver: (ì8@`qE@°
> °
> cannot allocate a new connection -- maximum of 16 connections already
> opened)
> Error in is(object, Cl) :
> error in evaluating the argument 'conn' in selecting a method for function
> 'dbSendQuery'
> Error in is(object, Cl) :
> error in evaluating the argument 'res' in selecting a method for function
> 'fetch'*
>
>
> *this is my DB connection function*
> *myDbConnect <- function (dbName, hostName) {
> drv<-MySQL()
> con <- dbConnect(drv, user="xyz", password="xyz",dbname = dbName, host
> = hostName)
> return(con)
> }*
>
>
> everytime i need ,Db connection , i used in this way:----
>
>
>
> This is the structure of my code:--
> main <- function ()
> {
> #Looping through subgroups
> for(sub_group_num_loopcounter in 1:sub_group_num_data_size[1])
> {
> #Fetching the where clause for the particular subgroup
> * sub_group_where_condition <-
> fetch(dbSendQuery(myDbConnect(dbName,hostName), paste(c("SELECT where_clause
> FROM sub_grp where
>
> num=",sub_group_num_data[sub_group_num_loopcounter,1]),collapse="")), n =
> -1) *
> }
> dbDisconnect(con)
> dbListConnections(MySQL())
> l<-list()
>
> }
>
> Where should i close the DB connection or use one single connection
> throughout the prograam.
>
>
>
> ------------------------------------------------------------------------
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help
mailing list