error connecting to redshift from an ec2 instance via RJDBC

2018-12-31T08:00:00Z

I'm running Rstudio in an ec2 instance and am trying to connect to a redshift database to read a table, getting the error:
Error in .jfindClass(as.character(driverClass)[1]) : class not found

library(RJDBC)
# connect to Amazon Redshift
.jclassLoader()$setDebug(1L)
JAR_DIR <- "/home/ec2-user/DM_march19/RedshiftJDBC42-1.2.16.1027.jar"
url <- "jdbc:redshift://ds-redshift-psbx-dsa.cblrlw3ocr3v.us-west-2.redshift.amazonaws.com:5439/cust_analytics_prd?user=xxxx&password=xxxxxxxxxxxxx"
drv <- JDBC("com.amazon.redshift.jdbc42.Driver", JAR_DIR, identifier.quote="`")

output:

RJavaClassLoader: added '/home/ec2-user/DM_march19/RedshiftJDBC42-1.2.16.1027.jar' to the URL class path loader
RJavaClassLoader: adding Java archive file '/home/ec2-user/DM_march19/RedshiftJDBC42-1.2.16.1027.jar' to the internal class path
RJavaClassLoader: added '/usr/lib64/R/library/RJDBC/java/RJDBC.jar' to the URL class path loader
RJavaClassLoader: adding Java archive file '/usr/lib64/R/library/RJDBC/java/RJDBC.jar' to the internal class path
RJavaClassLoader@24b8f952.findClass(com.amazon.redshift.jdbc42.Driver)
Error in .jfindClass(as.character(driverClass)[1]) : class not found

the redshift JAR file is on my client machine (a macbook) and works when i connect to the redshift database, so i copied it to my ec2 instance via the scp command, hoping that it would also work in that environment.

my ec2 R session_info:

sessionInfo()
R version 3.3.3 (2017-03-06)
Platform: x86_64-redhat-linux-gnu (64-bit)
Running under: Amazon Linux AMI 2017.03

locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=en_US.UTF-8
[4] LC_COLLATE=en_US.UTF-8 LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=en_US.UTF-8 LC_NAME=C LC_ADDRESS=C
[10] LC_TELEPHONE=C LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C

attached base packages:
[1] stats graphics grDevices utils datasets methods base

other attached packages:
[1] reprex_0.2.1 RJDBC_0.2-5 rJava_0.9-8 DBI_0.7

loaded via a namespace (and not attached):
[1] tools_3.3.3 fs_1.2.6 Rcpp_0.12.11 rlang_0.1.1

I tried to follow the instructions to use reprex() to create a reproducible example, but got the error message:

reprex()
No input provided and clipboard is not available.
Rendering reprex...

Clipboard on X11 requires 'xclip' (recommended) or 'xsel'.
Unable to put result on the clipboard. How to get it:

  • Capture what reprex() returns.
  • Consult the output file. Control via outfile argument.
    Path to outfile:
  • /tmp/RtmpEgr5oM/reprexc347865beb2/reprex_reprex.md
    Open the output file for manual copy?
    1: yes
    2: no

Selection: yes
Error: 'defer' is not an exported object from 'namespace:withr'

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.