0

I would like to use several jdbc connections to different MSSQL databases. In order to be able to "loop" through all databases connected, I was trying to set up the jdbc connectors as a list.

conn <- list ()
conn[1] <- dbConnect(drv_mssql,"jdbc:sqlserver://server1","USER","PASSWORD")
conn[2] <- dbConnect(drv_mssql,"jdbc:sqlserver://server2","USER","PASSWORD")

but...

I am not able to use conn[1] in the query statement

table <- dbGetQuery(conn[1],query_string)

The error message is: unable to find an inherited method for function ‘dbGetQuery’ for signature ‘"list", "character"’

Does anybody has an idea for me to get this done ?

Thank you very much in advance

Jürgen

  • I guess you are indexing your list in the wrong way. Try to see the output of "conn[1]" and "conn[[1]]". See eg http://stackoverflow.com/questions/21091202/how-to-index-an-element-of-a-list-object-on-r – Nieke Aerts Sep 15 '15 at 13:46
  • Dear Nieke, you are right.... Thank you very much for your hint and help. Best regards, Jürgen – frajuegies Sep 15 '15 at 13:52

0 Answers0