---------- Forwarded message ----------
From: Moumita Das <das.moumita.online@gmail.com>
Date: Sat, May 16, 2009 at 2:26 PM
Subject: Cannot allocate a new database connection error
To: r-help-request@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.

-- 
Thanks
Moumita



-- 
Thanks
Moumita

	[[alternative HTML version deleted]]


