Skip to content

Instantly share code, notes, and snippets.

@johndacosta
Last active June 29, 2019 07:17
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johndacosta/9223384 to your computer and use it in GitHub Desktop.
Save johndacosta/9223384 to your computer and use it in GitHub Desktop.
Connecting to SQL Server with R using RJDBC and com.microsoft.sqlserver.jdbc.SQLServerDriver on Mac OS X
# http://dacosta9.wordpress.com/2014/02/26/connecting-to-sql-server-with-r-with-rjdbc/
# reference document on RJDBC
# http://cran.r-project.org/web/packages/RJDBC/RJDBC.pdf
# install.packages("RJDBC",dep=TRUE)
library(RJDBC)
drv <- JDBC("com.microsoft.sqlserver.jdbc.SQLServerDriver" , "/Users/johndacosta/Downloads/sqljdbc_4.0/enu/sqljdbc4.jar" ,identifier.quote="`")
conn <- dbConnect(drv, "jdbc:sqlserver://192.172.1.210:55158;databaseName=master", "sa", "password")
d <- dbGetQuery(conn, "select * from sys.databases where database_id <= 4 ")
summary(d)
# R.Version()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment