SQLServer: SQLServerDriver class and methods

Description Usage Arguments Value References Examples

Description

SQLServer() creates a SQLServerDriver object and is based on the jTDS driver while dbConnect() provides a convenient interface to connecting to a SQL Server database using this driver.

Usage

1
2
3
4
5
SQLServer()

## S4 method for signature 'SQLServerDriver'
dbConnect(drv, server, file = NULL,
  database = NULL, type = NULL, port = NULL, properties = NULL)

Arguments

drv

An objected of class SQLServerDriver, or an existing SQLServerConnection. If a connection, the connection will be cloned.

server

the server address or recognised alias thereof.

file

defaults to using the server details file in $HOME/sql.yaml. The server details including type, port and any optional properties can be sourced from this file. If the server name is found in file, the details therein are used (and in particular, those provided in other arguments to this function are ignored). The connection method prefers server details to be provided in a "sql.yaml" file rather than provided as arguments to this function. If you wish to specify the details as parameters, ensure that either the file does not exist or that the server details are not in the YAML file.

database

the name of the database hosted on the server. If an empty string or NULL (default), a connection to the default database on server is assumed.

type

the server type. Must be either "sqlserver" or "sybase". Defaults to "sqlserver" when set to NULL.

port

the TCP/IP default port. This will be coerced to a string. Defaults to 1433 if set to NULL or an empty string (jTDS behaviour).

properties

One or more optional connection properties. in a named list (defaults to empty list). Note if you intend to set the useNTLMv2 property to 'true' from the default API value of 'false', you will need to make a specific authentication driver available to the SQL Server driver, although this has not worked particularly well in testing. See RSQLServer for more details. Should you wish to use Windows authentication to connect to the server, I recommend you set the following optional parameters: set useNTLMv2 to 'true', domain to your domain and user and password to your username and password on domain. jTDS' SSO functionality is flaky.

Value

SQLServer() returns an object of class SQLServerDriver; dbConnect() returns a SQLServerConnection object.

References

jTDS API doc for Driver class

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
## Not run: 
SQLServer()

## End(Not run)
# View sql.yaml file bundled in package
file <- system.file("extdata", "sql.yaml", package = "RSQLServer")
readLines(file)
# Connect using ~/sql.yaml file
## Not run: 
if (have_test_server()) {
 dbConnect(RSQLServer::SQLServer(), "TEST")
}
# Example where ~/sql.yaml does not exist or where the server
# is not in the YAML file.
dbConnect(RSQLServer::SQLServer(), server="11.1.111.11", port=1434,
   properties=list(useNTLMv2="true", domain="myco", user="me",
     password="asecret"))

## End(Not run)

imanuelcostigan/RSQLServer documentation built on May 18, 2019, 3:44 a.m.