NEWS
RJDBC 0.3-0
- RJDBC now supports options that can be defined at driver or
connection level which affect the defaults to some methods
such as fetch() or dbGetQuery(). They can be set either as
additional arguments to JDBC() or as a list passed in
dbOptions= parameter to dbConnect(). The connections inherit
driver parameters (if any).
The options are in principle available to any further functions
and can be checked using the new dbOption() generic which is
akin to getOption() in R, but it is mostly used by methods in
RJDBC.
Options currently used by RJDBC:
- autocommit - logical, if set during dbConnect() then
auto-commit on the connection is explicitly enabled (TRUE)
or disabled (FALSE) regardless of the initial state. If
not set, the auto-commit state is determined by the driver
and the default in JDBC is enabled. This option is
provided as a last-resort override for drivers that do not
support this option in the connection string and should be
rarely used. Note that auto-commit is always disabled for
the duration of transactions bracketed by dbBegin() and
dbCommit()/dbRollback().
- fetch.block (default: 2048L) - see fetch(block=)
- fetch.lossy (default: TRUE) - see fetch(lossy=)
- fetch.posix.ts (default: TRUE) - see fetch(posix.ts=)
- fetch.tz (default: "") - see fetch(tz=)
For example, to avoid lossy numeric conversions for all
connections of a given driver, it is possible to load the
driver such as
JDBC("org.postgresql.Driver", "postgresql-42.3.3.jar",
fetch.lossy=FALSE)
Similarly, it is possible to do so only for a particular
connection, such as if the MySQL driver was loaded without
such option then
dbConnect(MySQL, "jdbc:mysql://localhost/foo",
dbOptions=list(fetch.lossy=FALSE))
- Values which are representable as timestamps are now retrieved
in POSIX form (seconds since the epoch, same as POSIXct in
R). This behavior can be disabled using the posix.ts=FALSE
argument (see below) to match RDJBC 0.2 which used string
representation of date/time values.
- BIGINT type (64-bit integer) is now correctly handled as
non-representable (since it exceeds R's 53-bit double
precision) and will be returned as charecter vector unless
lossy=TRUE. Note that if non-lossy efficient storage is
desired, it is it possible to use lossy=FALSE and
bit64 package registered as a type map:
dbSetTypeMaps(BIGINT=bit64::as.integer64)
- fetch() (and by extension dbGetQuery() and dbReadTable())
gains new arguments:
lossy: logical, if FALSE then result columns which
contain numbers that may not be representable in IEEE
double format are returned as strings. If TRUE then any
numeric or decimal values are converted to doubles even if
that may result in a loss of precision. (see also #92)
The default is TRUE unless set by fetch.lossy dbOption (see
above).
posix.ts: logical, if TRUE (default) then result columns with
date/time values are fetched as timestamps in POSIX
form. This is most efficient and identical to POSIXct
representation in R, but it relies on drivers and DBMS
handling time zones properly. If FALSE then values are
returned as strings which is less efficient, but may be
used to uncover issues in date/time handling.
tz: string, defaults to "" which denotes R's current time
zone. Specifies the time zone in which the resulting POSIXct
date should be displayed (same as using .POSIXct(x, tz=tz)).
Note that this is only relevant for printing. The actual
timestamp is always an absolute point in time, but may be
shown in different time zones.
- JDBC connections now allow auto-commit mode to be disabled
either by options to the driver (connection string or
corresponding property - see you driver's docummentation if
supported) or by using the autocommit dbOption (see
above). Previously, the auto-commit mode was required to be
always enabled (see #97).
Note: the auto-commit mode should NOT be changed by SQL
commands, otherwise dbBegin()/dbCommit() won't know which
state to restore.
RJDBC 0.2-11
- add field.types= argument to dbWriteTable() (#87)
RJDBC 0.2-10 (2022-03-24)
- dbSendQuery() and dbSendUpdate() now remove named arguments
only from '...' but not from 'list=' to enable single-row
updates from data frames along the lines of 'list=iris[1,]'.
- dbWriteTable() failed for data frames with exactly one row,
because it used the form shown above for updates which will
fail with 'JDBC ERROR: Parameter at position 1 is not set'
since all elements are named and thus none were set.
- merging arguments from '...' and 'list=' was not always done
correctly, in some cases 'list=' would overwrite '...'
arguments.
(Note: all of the above are 0.2-9 regressions related to the
changes in handling of prepared statement arguments)
- add dbIsValid() methods for JDBCConnection and JDBCResult (#89)
RJDBC 0.2-9
- All Java-related errors are signalled by throwing error
conditions. If a Java error occurred, the condition will be of
the class JDBC.exception with the Java class names of the
excption as subclasses. Such objects have following slots:
- desc: string, description of the operation error
- jex: Java object, reference to the Java exception object
- statement: string (or NULL), executed statement
This allows the programmatic use of tryCatch() to selectively
catch exceptions and/or to use further Java utilities, such as
e$jex$printStackTrace()
- add 'schema=' to 'dbExistsTable()' (#84)
- check precision of numeric types and revert to string
representation if it is more than 15 to avoid loss of
precision at conversion time. (#83)
- 'NA's are supported in updates (#64)
- add 'findDrivers()' function which uses Java Service Provider
mechanism (in Java 1.6 and higher) to find all JDBC driver
classes on the class path.
- dbConnection() used to always try DriverManager first
(without properties) and only on failure it would use the
driver. However, DriverManager is static and never updates the
driver list, so it is inherently unreliable. Therefore we now
prefer the driver if specified and DriverManager will only be
used if the driver is NULL. (inspired by #45)
- Use collect + join when 'fetch()'ing results of unknown
length. This should improve performance for fetching results
with large number of rows. (mentioned in #50)
- Named arguments are removed from 'dbSendUpdate' and query
calls when populating prepared statements to allow for future
named arguments in the methods.
- 'dbBegin()' is implemented to disable auto-commit. Analogously,
'dbRollback()' and 'dbCommit()' perform the corresponding
function and then re-enable auto-commit. (see also #58)
- 'dbReadTable()' passes ... through to 'dbGetQuery'
RJDBC 0.2-8 (2020-03-10)
- re-use Java helper for subsequent fetch() calls on the same
result set which should make them more efficient.
- set 'has.completed' only if the fetch() has encountered
end of the result set (#73)
- add 'use.label' argument to fetch() - if set to 'FALSE'
then column names are used instead of labels (#74)
- change both semantics and defaults for 'append=FALSE' and
'overwrite=FALSE' in dbWriteTable() to match what is
documented in 'DBI': append=TRUE no longer requires the
existence of the target table and the options are mutally
exclusive (i.e. append=TRUE, overwrite=TRUE is illegal).
- dbWriteTable() also gains 'force=TRUE' option (disabled by
default) which skips the existence check for the target and
proceeds with removal and/or insertion regardless. This can be
useful with append=TRUE where the target is not a table and
thus would not pass the dbExistsTable() check (see #27).
- dbRemoveTable() returns TRUE on success (#20). On failure it
will fail with an error if silent=FALSE (as it always did so
far) or return FALSE if silent=TRUE.
- JDBC errors are reported such that the statement is shown at
the end. Previously the statement preceded the JDBC error, so
long statements caused errors to be truncated (#32). This also
opens up the possibility of more structured error objects.
- n, block and use.label are now passed through from
dbGetQuery() to fetch() (#44)
RJDBC 0.2-7 (2018-01-24)
- cosmetic changes to appease CRAN
RJDBC 0.2-6
- move java-src to java
- add schema= argument to dbGetTables() and dbListTables()
- support vectorized version of dbSendUpdate() which uses
batch-inserts for more efficient loading. Note that only
prepared statements work for now.
- use column labels instead of names (#36)
- dbColumnInfo() will return the column label in ‘name’ and
column name in ‘field.name’ (which is optional, for
compatbility).
RJDBC 0.2-5 (2014-12-19)
- fix bug in dbUnloadDriver() returning NULL instead of FALSE
- added block argument to fetch() currently defaulting to 2048
which controls the fetch size.
Note that 0.2-4 has set this to the stride which was much too
big for some databases therefore it is now configurable.
(issue #10)
- recover if setFetchSize() fails since some drivers don't take
it as a hint and fail regardless (issue #11)
RJDBC 0.2-4 (2014-06-26)
- set fetch size to match the capacity for better performance
with some drivers. (thanks Jesse Rohland)
- close DB objects explicitly (issue #4) to avoid Oracle DB
running out of resources
- add support for dbHasCompleted() even in older DBI versions
RJDBC 0.2-3 (2013-12-14)
- fix duplicate connection object (issue #1)
RJDBC 0.2-2 (2013-12-03)
- add dbGetTables() and dbGetFields() which are similar to
dbListTable() and dbListFields() but return a full data frame
as obtained from the corresponding JDBC calls.
- add support for stored procedure call JDBC syntax.
Currently only IN parameters are supported since
DBI doesn't provide a way to retrieve OUT parameters.
- JDBC now uses path.expand() on the classPath components
RJDBC 0.2-1 (2012-12-02)
- add support for dbWriteTable(..., append=TRUE)
- pass any additional arguments to dbConnect() as properties to
the connection
- use prepared statements only if parameters are passed,
otherwise use simple statements (this allows to work around
bugs in drivers that do not support prepared statements
properly)
- dbGetQuery() explicitly closes the statement before it returns
to work arround issues in the Teradata driver.
RJDBC 0.2-0 (2012-10-29)
- use Java code to fetch results -- it should result in much higher
throughput in pulling result sets from the database. It is
also more efficient to use fetch() with n specified
(especially if you know it in advance) than relying on
n = -1. The latter will try first run with n = 32k and then
continue with n = 512k chunks and paste the results which is
inherently slow (still much faster than the 0.1-x way which
was fetching one record at a time).
RJDBC 0.1-6 (2011-03-10)
- fix a typo in dbClearResult
- map NAs in query parameters into NULLs
(thanks to Axel Klenk)
- explicitly close statements right away (Oracle seems to need this)
(thanks to Axel Klenk)
- add "stat" slot (Statement object) to JDBCResult class to make sure
the statement lives long enough to not close the result set
- convert NULLs into NAs in numeric columns
RJDBC 0.1-5 (2007-10-07)
- instantiate driver's class and use a call to 'connect' as a
fall-back if the DriverManager fails to find a proper driver.
- fix SQL syntax in dbWriteTable (superfluous semicolon)
- fix a typo in prepared statement code
(thanks to Carl Grant for the last two bugfixes)
RJDBC 0.1-4
- added SQL error information to most JDBC errors
- use .jfindClass to load drivers
RJDBC 0.1-3 (2007-02-22)
- remove beforeFirst() as some DBMS don't like it. This also
allows a sequential use of fetch() with a limit to load data
in chunks.
- fix a bug that caused NULL entries in string columns to fail
in fetch()
RJDBC 0.1-2 (2007-01-24)
- fix dbDisconnect return value and update manuals
RJDBC 0.1-1
- added pre-compiled statements and proper dbWriteTable
RJDBC 0.1-0
- drop pgsql access, switch to DBI
RJDBC 0.0-3
- add direct insert support for pgsql
RJDBC 0.0-2
- added converson of tables to data.frames
RJDBC 0.0-1
- added type conversion (int, double, string)
RJDBC 0.0-0