I'm a novice at R, but our anization recently started using code based in R that reads from SQL Server. I did all the downloads required and am trying to run the following code in the instructions below:
In R, use the following command to install DatabaseConnector install.packages("DatabaseConnector")
Windows authentication for SQL Server: To be able to use Windows authentication for SQL Server (and PDW), you must install the JDBC driver. Download version 9.2.0 .zip from Microsoft and extract its contents to a folder. In the extracted folder you will find the file sqljdbc_9.2/enu/auth/x64/mssql-jdbc_auth-9.2.0.x64.dll (64-bits) or ssqljdbc_9.2/enu/auth/x86/mssql-jdbc_auth-9.2.0.x86.dll (32-bits), which needs to be moved to location c:/temp
Test connection using script below:
Sys.setenv("PATH_TO_AUTH_DLL" = "c:/temp") conn <- connect(dbms = "sql server", server = "*CaboodleServerName", pathToDriver = "c:/temp") dbGetQuery(conn, "SELECT COUNT(*) FROM OMOP.cdm.concept") disconnect(conn)
I get the following error and I'm not sure what to do to resolve it. Any help would be appreciated
> Sys.setenv("PATH_TO_AUTH_DLL" = "C:/Users/LASCHE/Documents/OMOP/Jar")
> Sys.setenv("DATABASECONNECTOR_JAR_FOLDER" = "C:/Users/LASCHE/Documents/OMOP/Jar")
> conn <- connect(dbms = "sql server", server = "caboodlesql62d",pathToDriver = "C:/Users/LASCHE/Documents/OMOP/Jar")
Connecting using SQL Server driver
- Using Windows integrated security
Looking for authentication DLL in path specified in PATH_TO_AUTH_DLL: C:/Users/LASCHE/Documents/OMOP/Jar
Error in .jcall("RJavaTools", "Ljava/lang/Object;", "invokeMethod", cl, :
java.io.IOException: Failed to get field handle to set library path
> dbGetQuery(conn, "SELECT COUNT(*) FROM OMOP.cdm.concept")
Error in h(simpleError(msg, call)) :
error in evaluating the argument 'conn' in selecting a method for function 'dbGetQuery': object 'conn' not found
> disconnect(conn)
Error: object 'conn' not found