importJDBC: Import From a JDBC-Compatible Database

Description Usage Arguments Details Value Time Zone Handling Note See Also Examples

Description

Imports data from a database using JDBC drivers.

Usage

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

Arguments

sqlQuery

the SQL query string describing the data to be retreived from the database. Required if table is not provided.

table

a string specifying the name of the table to import. Required if sqlQuery is not provided. Implies sqlQuery="SELECT * FROM <table>".

driverClass

a string containing the name of the Java class for the required JDBC driver.

con

the JDBC connection string.

user

a string specifying the user name with access to the database.

password

a string containing the password for the given user name on the database.

keepAlive

a logical. If TRUE, keeps the database connection alive after executing the query. The default is FALSE.

bigdata

unsupported 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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
## 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)

sjdbc documentation built on May 1, 2021, 1:08 a.m.

Related to importJDBC in sjdbc...