Hi,
I am attempting to connect the DatabaseConnector
package for R to an Amazon Redshift instance that contains data in CDM v5. I am currently trying to do this as part of running the CohortMethod
package, but I’ve had the same problem with other OHDSI packages that use DatabaseConnector
.
The error I receive is:
Connecting using Redshift driver
Error in .jcall(drv@jdrv, "Ljava/sql/Connection;", "connect", as.character(url)[1], :
org.postgresql.util.PSQLException: Connection refused. Check that the hostname and
port are correct and that the postmaster is accepting TCP/IP connections.
The code (details obscured) I run to receive this error is:
library(DatabaseConnector)
connection <- DatabaseConnector::connect(
DatabaseConnector::createConnectionDetails(
dbms = "redshift",
server = "aaaa.us-east-1.redshift.amazonaws.com/bbbb",
user = "cccc",
password = "dddd"
)
)
However, I am able to connect using the same connection details with the RPostgreSQL
library from CRAN:
library (RPostgreSQL)
connection <- DBI::dbConnect(
DBI::dbDriver("PostgreSQL"),
host = "aaaa.us-east-1.redshift.amazonaws.com",
port = "5439",
dbname = "bbbb",
user = "cccc",
password = "dddd"
)
This works. I have taken advantage of this fact to run other OHDSI packages such as StudyProtocols
by re-writing functions such as extractAndWriteToFile
to use RPostgreSQL
, but I’d prefer a less hacky solution!
Can anyone suggest what I might be doing wrong?
Thanks