H2: H2 engine

Description Usage Arguments Details Value See Also Examples

View source: R/class.R

Description

H2 creates a new DBI driver that can be used to start connections.

Usage

1
2
 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 NA for no quoted identifiers.

jars

pathname to H2 jar file. If omitted it will use the version of H2 included in RH2.

...

further arguments passed to .jpackage

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

dbConnect

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
## 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)

RH2 documentation built on May 1, 2019, 9:26 p.m.

Related to H2 in RH2...