importJDBC
Import From a JDBC-Compatible Database

Description

Imports data from a database using JDBC drivers.

Usage

importJDBC(sqlQuery, table, driverClass = sjdbcOptions()$driverClass,
    con = sjdbcOptions()$con, user = sjdbcOptions()$user,
    password = sjdbcOptions()$password,
    keepAlive = sjdbcOptions()$keepAlive, bigdata = FALSE)

Arguments

sqlQuerythe SQL query string describing the data to be retreived from the database. Required if table is not provided.
tablea string specifying the name of the table to import. Required if sqlQuery is not provided. Implies sqlQuery="SELECT * FROM <table>".
driverClassa string containing the name of the Java class for the required JDBC driver.
conthe JDBC connection string.
usera string specifying the user name with access to the database.
passworda string containing the password for the given user name on the database.
keepAlivea logical. If TRUE, keeps the database connection alive after executing the query. The default is FALSE.
bigdataunsupported in this version. Exists for compatibility with Spotfire S+.

Details

Imports data from the database using the JDBC driver specified in driverClass. The required JDBC driver must be loaded in sjdbc before use. See loadJDBCDriver for details.
Database connections are closed by default after the query executes, unless keepAlive is set to TRUE. If keepAlive = TRUE, the connection remains open, and successive database commands can reuse the open connection if and only if the same values for driverClass, con, user, and password are supplied.
Value
returns a data.frame containing the requested data.
Time Zone Handling
Times, Dates, and Timestamps that the datebase returns are assumed to be GMT. The resulting timeDate objects are created in GMT, without conversion. If you know the time zone of the incoming data, you can specify an alternative time zone for the timeDate objects by setting options("time.zone") prior to import. For further details, see the class.timeDate help file.
Note
Character data can be imported either as character or as factor. importJDBC uses the value of options(stringsAsFactors) to determine how to import the data.
Some arguments can also be set using sjdbcOptions.
See Also
loadJDBCDriver, sjdbcOptions
Examples
## Not run: 
importJDBC(driverClass="com.microsoft.sqlserver.jdbc.SQLServerDriver", 
	    con="jdbc:sqlserver://qadb-s2k:1433;databaseName=testdb;user=testqa;password=testqa;", 
	    sqlQuery="SELECT * FROM FUEL_FRAME")

importJDBC(driverClass="COM.ibm.db2.jdbc.net.DB2Driver", con="jdbc:db2://qadb1:6789/QATESTDB", user="testqa", password="testqa", sqlQuery="SELECT * FROM FUEL_FRAME") ## End(Not run)

Package sjdbc version 6.0.0-69
Package Index