Skip to content

Add <JDBCConnection> backend #1359

@nviraj

Description

@nviraj

Hi,

I am using “pool” with “RJDBC” and “dbplyr” packages to connect to Athena tables.
However I see the following warning.

Warning: <JDBCConnection> uses an old dbplyr interface
ℹ Please install a newer version of the package or contact the maintainer

This has been slightly tricky to pinpoint. Initially I thought it had something to do with RJDBC but it does not seem to be the case, as seen here.
I subsequently reported the issue to Pool, but it does not seem to be originating from there as well as I could replicate the issue using a DBI connection as well as Pool.

It was easier to generate a reprex using PostgreSQL Docker and JDBC, and the issue does not seem to be database specific. Please let me know if I am doing something incorrectly or need to report this elsewhere.

Steps to reproduce:

1. Create docker image to connect to using the official image:
docker run --network=host --name postgresdb_reprex -e POSTGRES_PASSWORD=mysecretpassword -e POSTGRES_USER=postgres -d postgres

2. Download JAR file from here
Alternatively you can use the attached Project which contains the script and the JAR file for Windows.
pool_issue.zip

3. Run reprex code
reprex.R contains the actual code. Running through
reprex::reprex(input = "reprex.R", venue = "gh", session_info = TRUE)

Reprex Content:

library(DBI)
#> Warning: package 'DBI' was built under R version 4.3.1
library(pool)
#> Warning: package 'pool' was built under R version 4.3.1
library(dplyr)
#> Warning: package 'dplyr' was built under R version 4.3.1
#> 
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#> 
#>     filter, lag
#> The following objects are masked from 'package:base':
#> 
#>     intersect, setdiff, setequal, union
library(RJDBC)
#> Warning: package 'RJDBC' was built under R version 4.3.1
#> Loading required package: rJava

# Connection details for docker image of postgres
connection_url <- "jdbc:postgresql://localhost:5432/postgres"
username <- "postgres"
password <- "mysecretpassword"
# Where is the JAR file stored
# JDBC downloaded through https://jdbc.postgresql.org/download/
jdbc_path <- "postgresql-42.6.0.jar"

# Create a JDBC driver
driver <-
  RJDBC::JDBC(
    driverClass = "org.postgresql.Driver",
    classPath = jdbc_path,
    identifier.quote = "'"
  )

# Establish connection through DBI
conn <- DBI::dbConnect(driver, connection_url,
  user = username,
  password = password
)
# Write table to database using DBI
if (!DBI::dbExistsTable(conn, "mtcars")) {
  DBI::dbWriteTable(conn, "mtcars", mtcars)
} else {
  base::message("Table already exists!")
}

# Create a Pool connection
con <- pool::dbPool(
  drv = driver, url = connection_url,
  user = username,
  password = password
)

# Connect to table
mtcars_db <- dplyr::tbl(con, "mtcars")
#> Warning: <JDBCConnection> uses an old dbplyr interface
#> ℹ Please install a newer version of the package or contact the maintainer
#> This warning is displayed once every 8 hours.

# Run sample query
mtcars_db %>%
  dplyr::filter(cyl == 8) %>%
  utils::head()
#> # Source:   SQL [6 x 11]
#> # Database: JDBCConnection
#>     mpg   cyl  disp    hp  drat    wt  qsec    vs    am  gear  carb
#>   <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1  18.7     8  360    175  3.15  3.44  17.0     0     0     3     2
#> 2  14.3     8  360    245  3.21  3.57  15.8     0     0     3     4
#> 3  16.4     8  276.   180  3.07  4.07  17.4     0     0     3     3
#> 4  17.3     8  276.   180  3.07  3.73  17.6     0     0     3     3
#> 5  15.2     8  276.   180  3.07  3.78  18       0     0     3     3
#> 6  10.4     8  472    205  2.93  5.25  18.0     0     0     3     4

Created on 2023-09-04 with reprex v2.0.2

Session info
sessioninfo::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#>  setting  value
#>  version  R version 4.3.0 (2023-04-21 ucrt)
#>  os       Windows 11 x64 (build 22621)
#>  system   x86_64, mingw32
#>  ui       RTerm
#>  language (EN)
#>  collate  English_India.utf8
#>  ctype    English_India.utf8
#>  tz       Asia/Calcutta
#>  date     2023-09-04
#>  pandoc   3.1.1 @ C:/Program Files/RStudio/resources/app/bin/quarto/bin/tools/ (via rmarkdown)
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────
#>  ! package     * version date (UTC) lib source
#>    blob          1.2.4   2023-03-17 [1] CRAN (R 4.3.1)
#>    cli           3.6.1   2023-03-23 [1] CRAN (R 4.3.1)
#>    DBI         * 1.1.3   2022-06-18 [1] CRAN (R 4.3.1)
#>    dbplyr        2.3.3   2023-07-07 [1] CRAN (R 4.3.1)
#>    digest        0.6.33  2023-07-07 [1] CRAN (R 4.3.1)
#>    dplyr       * 1.1.2   2023-04-20 [1] CRAN (R 4.3.1)
#>    evaluate      0.21    2023-05-05 [1] CRAN (R 4.3.1)
#>    fansi         1.0.4   2023-01-22 [1] CRAN (R 4.3.1)
#>    fastmap       1.1.1   2023-02-24 [1] CRAN (R 4.3.1)
#>    fs            1.6.3   2023-07-20 [1] CRAN (R 4.3.1)
#>    generics      0.1.3   2022-07-05 [1] CRAN (R 4.3.1)
#>    glue          1.6.2   2022-02-24 [1] CRAN (R 4.3.1)
#>    htmltools     0.5.6   2023-08-10 [1] CRAN (R 4.3.1)
#>    knitr         1.43    2023-05-25 [1] CRAN (R 4.3.1)
#>    later         1.3.1   2023-05-02 [1] CRAN (R 4.3.1)
#>    lifecycle     1.0.3   2022-10-07 [1] CRAN (R 4.3.1)
#>    magrittr      2.0.3   2022-03-30 [1] CRAN (R 4.3.1)
#>    pillar        1.9.0   2023-03-22 [1] CRAN (R 4.3.1)
#>    pkgconfig     2.0.3   2019-09-22 [1] CRAN (R 4.3.1)
#>    pool        * 1.0.1   2023-02-21 [1] CRAN (R 4.3.1)
#>    purrr         1.0.2   2023-08-10 [1] CRAN (R 4.3.1)
#>    R.cache       0.16.0  2022-07-21 [1] CRAN (R 4.3.1)
#>    R.methodsS3   1.8.2   2022-06-13 [1] CRAN (R 4.3.0)
#>    R.oo          1.25.0  2022-06-12 [1] CRAN (R 4.3.0)
#>    R.utils       2.12.2  2022-11-11 [1] CRAN (R 4.3.1)
#>    R6            2.5.1   2021-08-19 [1] CRAN (R 4.3.1)
#>    Rcpp          1.0.11  2023-07-06 [1] CRAN (R 4.3.1)
#>    reprex        2.0.2   2022-08-17 [1] CRAN (R 4.3.1)
#>  D rJava       * 1.0-6   2021-12-10 [1] CRAN (R 4.3.0)
#>    RJDBC       * 0.2-10  2022-03-24 [1] CRAN (R 4.3.1)
#>    rlang         1.1.1   2023-04-28 [1] CRAN (R 4.3.1)
#>    rmarkdown     2.24    2023-08-14 [1] CRAN (R 4.3.1)
#>    rstudioapi    0.15.0  2023-07-07 [1] CRAN (R 4.3.1)
#>    sessioninfo   1.2.2   2021-12-06 [1] CRAN (R 4.3.1)
#>    styler        1.10.2  2023-08-29 [1] CRAN (R 4.3.1)
#>    tibble        3.2.1   2023-03-20 [1] CRAN (R 4.3.1)
#>    tidyselect    1.2.0   2022-10-10 [1] CRAN (R 4.3.1)
#>    utf8          1.2.3   2023-01-31 [1] CRAN (R 4.3.1)
#>    vctrs         0.6.3   2023-06-14 [1] CRAN (R 4.3.1)
#>    withr         2.5.0   2022-03-03 [1] CRAN (R 4.3.1)
#>    xfun          0.40    2023-08-09 [1] CRAN (R 4.3.1)
#>    yaml          2.3.7   2023-01-23 [1] CRAN (R 4.3.0)
#> 
#>  [1] C:/Users/viraj/AppData/Local/R/win-library/4.3
#>  [2] C:/Program Files/R/R-4.3.0/library
#> 
#>  D ── DLL MD5 mismatch, broken installation.
#> 
#> ──────────────────────────────────────────────────────────────────────────────

4. Stop and remove Docker image

docker stop postgresdb_reprex
docker rm -f postgresdb_reprex

Please let me know if you need any further details. Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions