Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patching RH2 to get H2 version 1.4.200 #48

Open
ggrothendieck opened this issue Nov 26, 2021 · 0 comments
Open

Patching RH2 to get H2 version 1.4.200 #48

ggrothendieck opened this issue Nov 26, 2021 · 0 comments

Comments

@ggrothendieck
Copy link
Owner

ggrothendieck commented Nov 26, 2021

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant