Version: | 0.2.5 |
Date: | 2025-04-11 |
Title: | DBI/RJDBC Interface to H2 Database |
Description: | DBI/RJDBC interface to h2 database. h2 version 2.3.232 is included. |
Depends: | chron, methods, RJDBC, rJava |
SystemRequirements: | java runtime |
License: | Mozilla Public License 1.1 |
URL: | https://github.com/dmkaplan2000/RH2 |
Packaged: | 2025-04-11 12:33:14 UTC; dmk |
NeedsCompilation: | no |
Author: | G. Grothendieck [aut],
"David M. Kaplan" |
Maintainer: | "David M. Kaplan" <dmkaplan2000@gmail.com> |
Repository: | CRAN |
Date/Publication: | 2025-04-11 16:10:02 UTC |
H2 engine
Description
H2
creates a new DBI driver that can be used to start connections.
Usage
H2(driverClass='org.h2.Driver',
identifier.quote="\"", jars = getOption("RH2.jars"), ...)
Arguments
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 |
Details
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).
Value
Returns a H2Driver
object that can be used in calls to
dbConnect
.
See Also
Examples
## 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 "H2Connection"
Description
Class representing a (DBI) database connection which uses H2 to connect to a database.
Generators
Objects can be created by call to dbConnect
of a
JDBC
driver.
Slots
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"
.
Extends
Class "JDBCConnection-class"
, directly.
Methods
No methods defined with class "H2Connection" in the signature.
See Also
Methods for the class ‘H2Connect’ in Package ‘H2’
Description
Methods for the class ‘H2Connection’ in Package ‘H2’.
Methods
- dbSendQuery
signature(conn = "H2Connection", statement="character")
- dbGetQuery
signature(conn = "H2Connection", statement="character")
- dbWriteTable
signature(conn = "H2Connection", name="character", value="data.frame")
signature(conn = "H2Connection", , name="character", value="ANY")
- dbDataType
signature(conn = "H2Connection", obj="ANY")
Class "H2Driver"
Description
A DBI driver to access the H2 databases.
Generators
Objects can be created by calls to H2
or dbDriver
.
Slots
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.
Extends
Class "JDBCDriver-class"
, directly.
Methods
No methods defined with class "H2Driver" in the signature.
See Also
Methods for the class JDBCDriver in Package ‘RJDBC’
Description
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.
Methods
- dbConnect
signature(drv = "H2Driver", ...)
Examples
## 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)
Class "H2Result"
Description
Representation of a DBI result set returned from a H2 connection.
Generators
Objects can be created by call to dbSendQuery
.
Slots
jr
:Java reference to the H2 result set
md
:Java reference to the H2 result set meta data
Extends
Class "DBIResult-class"
, directly.
Methods
No methods defined with class "H2Result" in the signature.
See Also
Methods for the class H2Result in Package ‘H2’
Description
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.
Methods
- fetch
signature(res = "H2Result", n="numeric")