sqldf
sqldf copied to clipboard
Patching RH2 to get H2 version 1.4.200
Until the RH2 maintainer updates RH2 with the new version of H2 this code will patch an existing RH2 installation provided that you have write permission in the java directory of the RH2 installation. This assumes that you are starting with a fresh installation of R (no loaded packages) and that the RH2 R package is already installed and that you have write permission to the RH2 directory in the R library. Just copy and paste the code below to R.
# start with a fresh instance of R
# install RH2 if not already installed
# install.packages("RH2")
# u is automatically set to the URL of latest jar file.
# It is something like this except possibly with different version number
# "https://search.maven.org/remotecontent?filepath=com/h2database/h2/2.1.214/h2-2.1.214.jar"
u <- "http://www.h2database.com/html/download.html" |>
readLines() |>
grep(pattern = "http.*Binary JAR", value = TRUE) |>
sub(pattern = ".*(https:.*jar).*", replacement = "\\1")
print(u)
# download jar file to temporary directory
z <- basename(u)
tmp <- tempdir() # create temporary dir
old.dir <- setwd(tmp) # go to it
download.file(u, z) # download u
# copy new jar file to RH2 installation and remove old one
# You must have write permission to it.
new.jar <- file.path(tmp, z)
old.jar <- dir(system.file("java", package = "RH2"), "h2.*jar$", full.names = TRUE)
if (basename(old.jar) != basename(new.jar)) {
file.copy(new.jar, dirname(old.jar))
file.remove(old.jar)
}
setwd(old.dir) # return to original directory
# test
library(RH2)
library(sqldf)
sqldf("select h2version()")
## H2VERSION()
## 1 2.1.214