Connecting R to embedded H2 database on RStudio -
i'm having hard time figuring out how connect r code embedded h2 database. seems rh2 tool go (library installed) there no working example on documentation nor on stackexchange or on google - @ least didn't find 1 (besides this). since i'm doing babysteps r, working example connect , retrieve data great!
the code must like
library(rh2) options(rh2.jars = "c:\\h2\\bin\\h2-1.4.187.jar") myh2 <- h2(driverclass="org.h2.driver", identifier.quote="\"", jars = getoption("rh2.jars")) con <- dbconnect(myh2, url = "jdbc:h2:c:\\data\\sample.h2.db", user = "admin", password = "ultrasafe123") dataframe = fetch(dbgetquery(con, "select * tablename"))
currently i'm getting:
error in .jfindclass(as.character(driverclass)[1]) : class not found` `driverclass="org.h2.driver"`
but that's how shown in documentation. did miss else? library? including library(rjdbc)
didn't either.
i solved myself:
library(rh2) myh2 <- h2('org.h2.driver', 'c:/h2/bin/h2-1.4.187.jar') ## location of h2 file: c:\data\data.h2.db con <- dbconnect(myh2, "jdbc:h2:c:/data", "user", "password") s <- "select * table column = 'value'" result = dbgetquery(con, s) dbdisconnect(con)
Comments
Post a Comment