Title: | DBI/RJDBC Interface to H2 Database |
---|---|
Description: | DBI/RJDBC interface to h2 database. h2 version 1.3.175 is included. |
Authors: | G. Grothendieck. Author of h2 is Thomas Mueller. |
Maintainer: | "David M. Kaplan" <[email protected]> |
License: | Mozilla Public License 1.1 |
Version: | 0.2.4 |
Built: | 2024-11-03 02:48:29 UTC |
Source: | https://github.com/dmkaplan2000/rh2 |
H2
creates a new DBI driver that can be used to start connections.
H2(driverClass='org.h2.Driver', identifier.quote="\"", jars = getOption("RH2.jars"), ...)
H2(driverClass='org.h2.Driver', identifier.quote="\"", jars = getOption("RH2.jars"), ...)
driverClass |
name of the Java class of the driver to load. If empty, it is assumed that corresponding drivers were loaded by other means. |
identifier.quote |
character to use for quoting identifiers in
automatically generated SQL statements or |
jars |
pathname to H2 jar file. If omitted it will use the version of H2 included in RH2. |
... |
further arguments passed to |
The H2
function initializes the Java VM, loads the H2 driver
and creates a proxy R object which can be used to a
call dbConnect
which actually creates a connection.
It handles "integer", "Date", chron "times", "POSIXct" and "numeric" classes using the H2 types of "integer", "date", "time", "timestamp" and "double precision". All other R classes are converted to "character" and stored as varchar(255).
Returns a H2Driver
object that can be used in calls to
dbConnect
.
## Not run: library(RJDBC) con <- dbConnect(H2(), "jdbc:h2:~/test", "sa", "") # create table, populate it and display it s <- 'create table tt("id" int primary key, "name" varchar(255))' dbSendUpdate(con, s) dbSendUpdate(con, "insert into tt values(1, 'Hello')") dbSendUpdate(con, "insert into tt values(2, 'World')") dbGetQuery(con, "select * from tt") # transfer a data frame to H2 and then display it from the database dbWriteTable(con, "BOD", BOD) dbGetQuery(con, "select * from BOD") dbDisconnect(con) # connect to a different version of H2 and show version con <- dbConnect(H2(jars = "c:/tmp2/h2-1.3.155.jar")) s <- "select VALUE from INFORMATION_SCHEMA.SETTINGS where NAME = 'info.VERSION'" dbGetQuery(con, s) dbDisconnect(con) ## End(Not run)
## Not run: library(RJDBC) con <- dbConnect(H2(), "jdbc:h2:~/test", "sa", "") # create table, populate it and display it s <- 'create table tt("id" int primary key, "name" varchar(255))' dbSendUpdate(con, s) dbSendUpdate(con, "insert into tt values(1, 'Hello')") dbSendUpdate(con, "insert into tt values(2, 'World')") dbGetQuery(con, "select * from tt") # transfer a data frame to H2 and then display it from the database dbWriteTable(con, "BOD", BOD) dbGetQuery(con, "select * from BOD") dbDisconnect(con) # connect to a different version of H2 and show version con <- dbConnect(H2(jars = "c:/tmp2/h2-1.3.155.jar")) s <- "select VALUE from INFORMATION_SCHEMA.SETTINGS where NAME = 'info.VERSION'" dbGetQuery(con, s) dbDisconnect(con) ## End(Not run)
Class representing a (DBI) database connection which uses H2 to connect to a database.
Objects can be created by call to dbConnect
of a
JDBC
driver.
jc
:Java object representing the connection.
identifier.quote
:Quote character to use for
quoting identifiers in automatically generated SQL
statements or NA
for no such quoting.
Usually the value is inherited from the
"H2Driver"
.
Class "JDBCConnection-class"
, directly.
No methods defined with class "H2Connection" in the signature.
JDBC
, "JDBCDriver"
Methods for the class ‘H2Connection’ in Package ‘H2’.
signature(conn = "H2Connection", statement="character")
signature(conn = "H2Connection", statement="character")
signature(conn = "H2Connection", name="character", value="data.frame")
signature(conn = "H2Connection", , name="character", value="ANY")
signature(conn = "H2Connection", obj="ANY")
A DBI driver to access the H2 databases.
Objects can be created by calls to H2
or dbDriver
.
identifier.quote
:Quote character to use for
identifiers in automatically generated SQL statements or NA
if quoted identifiers are not desired.
jdrv
:Java object reference to an instance of the driver if the driver can be instantiated by a default constructor. This object is only used as a fall-back when the driver manager fails to find a driver.
Class "JDBCDriver-class"
, directly.
No methods defined with class "H2Driver" in the signature.
Methods for the class ‘H2Driver’ in Package ‘H2’. In addition to methods
listed here there are methods inherited from JDBCDriver
.
dbConnect
creates a new H2 connection.
signature(drv = "H2Driver", ...)
## Not run: # in memory database con <- dbConnect(H2(), "jdbc:h2:mem:") dbDisconnect(con) # external database con <- dbConnect(H2(), "jdbc:h2:~/test") dbDisconnect(con) # same but run in MySQL compatibility mode con <- dbConnect(H2(), "jdbc:h2:~/test;MODE=MYSQL") ## End(Not run)
## Not run: # in memory database con <- dbConnect(H2(), "jdbc:h2:mem:") dbDisconnect(con) # external database con <- dbConnect(H2(), "jdbc:h2:~/test") dbDisconnect(con) # same but run in MySQL compatibility mode con <- dbConnect(H2(), "jdbc:h2:~/test;MODE=MYSQL") ## End(Not run)
Representation of a DBI result set returned from a H2 connection.
Objects can be created by call to dbSendQuery
.
jr
:Java reference to the H2 result set
md
:Java reference to the H2 result set meta data
Class "DBIResult-class"
, directly.
No methods defined with class "H2Result" in the signature.
Methods for the class ‘H2Result’ in Package ‘H2’.
fetch
retrieves the content of the result set in the form of a
data frame.
Other methods are inherited from the RJDBC package.
signature(res = "H2Result", n="numeric")