Skip to content

Instantly share code, notes, and snippets.

@haydenbspence
Last active December 6, 2023 02:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save haydenbspence/fd643dff5c2b531ecfb5e6c9df0d4de6 to your computer and use it in GitHub Desktop.
Save haydenbspence/fd643dff5c2b531ecfb5e6c9df0d4de6 to your computer and use it in GitHub Desktop.
DatabaseConnector jdbc connection
# DatabaseConnector Documentation for SQL Server
# http://ohdsi.github.io/DatabaseConnector/articles/Connecting.html
# JDBC Driver Download
# https://learn.microsoft.com/en-us/sql/connect/jdbc/release-notes-for-the-jdbc-driver?view=sql-server-ver15#92-releases
# Microsoft documentation on JDBC strings for SQL Server
# https://learn.microsoft.com/en-us/sql/connect/jdbc/building-the-connection-url?view=sql-server-ver16
# For integrated security, remove the user argument
# https://github.com/OHDSI/DatabaseConnector/blob/be58698d06b2d03940117c7bc5cf7aa1126fec8a/man-roxygen/DefaultConnectionDetails.R#L41
# {SQL_SERVER_ADDRESS} this is the server address you are connecting to
# {SQL_SERVER_PORT} typically this is 1433
# {DATABASE_NAME} is the specific database you are connecting to
# {YOUR_USERNAME} is your windows domain name. Usually {DOMAIN}/{DEPT}{FIRST_INITIAL}{LAST_NAME}
library(DatabaseConnector)
con <- connect(dbms = "sql server", connectionString = "
jdbc:sqlserver://{SQL_SERVER_ADDRESS}:{SQL_SERVER_PORT};
connectRetryInterval=10;
maxRetryCount=1;
maxResultBuffer=-1;
sendTemporalDataTypesAsStringForBulkCopy=true;
delayLoadingLobs=true;
useFmtOnly=false;
useBulkCopyForBatchInsert=false;
cancelQueryTimeout=-1;
sslProtocol=TLS;
jaasConfigurationName=SQLJDBCDriver;
statementPoolingCacheSize=0;
serverPreparedStatementDiscardThreshold=10;
enablePrepareOnFirstPreparedStatementCall=false;
fips=false;
socketTimeout=0;
authentication=NotSpecificed;
authenticationSchema=nativeAuthentication;
xopenStates=false;
datetimeParameterType=default;
replication=false;
trustStoreType=JKS;
trustServerCertificate=false;
TransparentNetworkIPResolution=true;
iPAddressPerference=IPv4First;
serverNameAsACE=false;
sendStringParameterAsUnicode=true;
selectMethod=direct;
responseBuffering=adaptive;
queryTimeout=-1;
packetSize=8000;
multiSubnetFailover=false;
loginTimeout=30;
lastUpdateCount=true;
preparemethod=prepexec;
encrypt=true;
disableStatementPooling=true;
database={DATABASE_NAME};
columnEncryptionSetting=Disabled;
applicationName=Microsoft JDBC Driver for SQL Server;
applicationIntent=readwrite;",
user = "{YOUR USERNAME}", # remove if integrated security
password = password)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment