Redshift connection error : could not find function "JDBC" - r

When executing the code verbatim from the Amazon reference, the driver function is not found. I've installed and loaded the RJDBC package, however, the JDBC function cannot be found. Please forgive the output below. I included it to show the verbatim code from the reference is returning an error for me.
platform x86_64-apple-darwin15.6.0
arch x86_64
os darwin15.6.0
system x86_64, darwin15.6.0
status
major 3
minor 5.1
version.string R version 3.5.1 (2018-07-02)
nickname Feather Spray
> library(RJDBC)
Loading required package: rJava
Unable to find any JVMs matching version "(null)".
No Java runtime present, try --request to install.
Error: package or namespace load failed for ‘rJava’:
.onLoad failed in loadNamespace() for 'rJava', details:
call: dyn.load(file, DLLpath = DLLpath, ...)
error: unable to load shared object '/Library/Frameworks/R.framework/Versions/3.5/Resources/library/rJava/libs/rJava.so':
dlopen(/Library/Frameworks/R.framework/Versions/3.5/Resources/library/rJava/libs/rJava.so, 6): Library not loaded: /Library/Java/JavaVirtualMachines/jdk-9.jdk/Contents/Home/lib/server/libjvm.dylib
Referenced from: /Library/Frameworks/R.framework/Versions/3.5/Resources/library/rJava/libs/rJava.so
Reason: image not found
Error: package ‘rJava’ could not be loaded
In addition: Warning message:
In system("/usr/libexec/java_home", intern = TRUE) :
running command '/usr/libexec/java_home' had status 1
>
> # download Amazon Redshift JDBC driver
> download.file('http://s3.amazonaws.com/redshift-downloads/drivers/RedshiftJDBC41-1.1.9.1009.jar','RedshiftJDBC41-1.1.9.1009.jar')
trying URL 'http://s3.amazonaws.com/redshift-downloads/drivers/RedshiftJDBC41-1.1.9.1009.jar'
Content type 'application/x-java-archive' length 2055261 bytes (2.0 MB)
==================================================
downloaded 2.0 MB
>
> # connect to Amazon Redshift
> driver <- JDBC("com.amazon.redshift.jdbc41.Driver", "RedshiftJDBC41-1.1.9.1009.jar", identifier.quote="`")
Error in JDBC("com.amazon.redshift.jdbc41.Driver", "RedshiftJDBC41-1.1.9.1009.jar", :
could not find function "JDBC"

Related

RWeka installation under Rstudio on Mac

I tried to find solutions from previous posts, but they do not solve my problem.
I am using macOS High Sierra and have Java installed. Below is the error reported by Rstudio. Also, rJava, Mac, and R are really messy with each other. I found this post but still does not work.
https://github.com/MTFA/CohortEx/wiki/Run-rJava-with-RStudio-under-OSX-10.10,-10.11-(El-Capitan)-or-10.12-(Sierra)
///////////////////
library(RWeka)
Error: package or namespace load failed for ‘RWeka’:
.onLoad failed in loadNamespace() for 'rJava', details:
call: dyn.load(file, DLLpath = DLLpath, ...)
error: unable to load shared object '/Library/Frameworks/R.framework/Versions/3.4/Resources/library/rJava/libs/rJava.so':
dlopen(/Library/Frameworks/R.framework/Versions/3.4/Resources/library/rJava/libs/rJava.so, 6): Library not loaded: #rpath/libjvm.dylib
Referenced from: /Library/Frameworks/R.framework/Versions/3.4/Resources/library/rJava/libs/rJava.so
Reason: image not found
In addition: Warning message:
package ‘RWeka’ was built under R version 3.4.4
I met the same question and I found this is helpful.
Cannot load R xlsx package on Mac OS 10.11
1.In terminal enter the following to relink Java correctly:
sudo R CMD javareconf
2.Back in R (or RStudio) install the rJava package from source:
install.packages("rJava",type='source')
Then
library(rJava)
and
library(RWeka)
should work.

Incompatible library version RSiena

I'm trying to load the RSiena package into R, but keep getting this error message:
Error: package or namespace load failed for ‘RSiena’:
.onLoad failed in loadNamespace() for 'tcltk', details:
call: dyn.load(file, DLLpath = DLLpath, ...)
error: unable to load shared object '/Library/Frameworks/R.framework/Versions/3.4/Resources/library/tcltk/libs/tcltk.so':
dlopen(/Library/Frameworks/R.framework/Versions/3.4/Resources/library/tcltk/libs/tcltk.so, 10): Library not loaded: /opt/X11/lib/libfontconfig.1.dylib
Referenced from: /usr/local/lib/libtk8.6.dylib
Reason: Incompatible library version: libtk8.6.dylib requires version 11.0.0 or later, but libfontconfig.1.dylib provides version 10.0.0
I tried installing three ways:
install.packages("RSiena") , install.packages("RSiena", repos="http://R-Forge.R-project.org") , and installing straight from tgz file (from https://cran.r-project.org/web/packages/RSiena/index.html).
The first two installation methods do not give any error and say The downloaded binary packages are in /var/folders/mk/__r_sbzn5mx88x04mrlycsg00000gq/T//RtmpbxlMY8/downloaded_packages.The third option gives this message Error in install.packages : type == "both" cannot be used with 'repos = NULL'
None allow me to load the package. I'm working with R version 3.4.3 (2017-11-30) in RStudio Version 1.1.423 on Mac OS X El Capitan (version 10.11.6).
I've tried uninstalling and reinstalling. I'm not sure how else to troubleshoot this issue.
The most recent version (RSiena v.1.2.26) of rsiena addresses tcltk issues, and is now available on Github here: https://github.com/snlab-nl/rsiena.
SOLUTION. I installed XQuartz from xquartz.macosforge.org and now the package loads successfully.

rJava does not run on macOS Sierra

I am using macOS Sierra and R version 3.4.0.
I installed the package "rJava" using RStudio:
install.packages("rJava")
Warning in install.packages :
cannot open URL 'https://cran.rstudio.com/bin/macosx/el-capitan/contrib/3.4/PACKAGES.rds': HTTP status was '404 Not Found'
trying URL 'https://cran.rstudio.com/bin/macosx/el-capitan/contrib/3.4/rJava_0.9-8.tgz'
Content type 'application/x-gzip' length 627959 bytes (613 KB)
==================================================
downloaded 613 KB
The downloaded binary packages are in
/var/folders/tq/f5jbfqp97y52w_y7byn05_fw0000gn/T//RtmpTdEVbA/downloaded_packages
Then when I try to run rJava I get:
> require(rJava)
Loading required package: rJava
Error: package or namespace load failed for ‘rJava’:
.onLoad failed in loadNamespace() for 'rJava', details:
call: dyn.load(file, DLLpath = DLLpath, ...)
error: unable to load shared object '/Library/Frameworks/R.framework/Versions/3.4/Resources/library/rJava/libs/rJava.so':
dlopen(/Library/Frameworks/R.framework/Versions/3.4/Resources/library/rJava/libs/rJava.so, 6): Library not loaded: #rpath/libjvm.dylib
Referenced from: /Library/Frameworks/R.framework/Versions/3.4/Resources/library/rJava/libs/rJava.so
Reason: image not found
R, rJava and Java are little bit messy in macOS. In general, you have to make sure to properly configure all the elements. There is a clash between Oracle's and Apple's version.
Take a look here for very detailed instructions: R, Java, rJava and macOS adventures
I don't post the content here - it's quite long.

Using Rattle on Mac OS X Yosemite 10.10.5

I am having trouble loading rattle on my mac, I have been pushed around to download X11 but cant seem to find a working page.
When trying to invoke rattle with the simple
library(rattle)
It has a popup about X11 and continue brings you yo this link https://support.apple.com/en-us/HT201341.
And I get this when trying to use the Rcmdr work around
library(Rcmdr)
Error : .onLoad failed in loadNamespace() for 'tcltk', details:
call: dyn.load(file, DLLpath = DLLpath, ...)
error: unable to load shared object '/Library/Frameworks/R.framework/Versions/3.2/Resources/library/tcltk/libs/tcltk.so':
dlopen(/Library/Frameworks/R.framework/Versions/3.2/Resources/library/tcltk/libs/tcltk.so, 10): Library not loaded: /opt/X11/lib/libX11.6.dylib
Referenced from: /Library/Frameworks/R.framework/Versions/3.2/Resources/library/tcltk/libs/tcltk.so
Reason: image not found
In addition: Warning message:
running command ''/usr/bin/otool' -L '/Library/Frameworks/R.framework/Resources/library/tcltk/libs//tcltk.so'' had status 1
Error: package or namespace load failed for ‘Rcmdr’
xcode-select: note: no developer tools were found at '/Applications/Xcode.app', requesting install. Choose an option in the dialog to download the command line developer tools.
library(Rcmdr)
Error : .onLoad failed in loadNamespace() for 'tcltk', details:
call: fun(libname, pkgname)
error: X11 library is missing: install XQuartz from xquartz.macosforge.org
Error: package or namespace load failed for ‘Rcmdr’
install.packages("XQuartz")
--- Please select a CRAN mirror for use in this session ---
Warning message:
package ‘XQuartz’ is not available (for R version 3.2.1)
install.packages("tcltk")
Warning message:
package ‘tcltk’ is not available (for R version 3.2.1)
Any help here on getting Rattle to load with OS X Yosemite?
XQuartz isn't an R package, but rather an implementation of the X11 windowing system for Mac OS X. You need to install XQuartz to use the tcltk package in R, on which the Rcmdr depends, under Mac OS X.
See the Rcmdr installation notes for Mac OS X.
I hope this helps,
John

Rcmdr error when loading in OSX Yosemite

I'm trying do load Rcmdr and keep getting an error message.
I'm using Rstudio Version 0.98.1091 on a OSX Yosemite operating system.
I have done the following:
install.packages("Rcmdr")
trying URL'http://cran.rstudio.com/bin/macosx/mavericks/contrib/3.1/Rcmdr_2.1-5.tgz'
Content type 'application/x-gzip' length 5342987 bytes (5.1 Mb)
opened URL
==================================================
downloaded 5.1 Mb
However, when I try to load it, I get the following error:
> library(Rcmdr)
Loading required package: splines
Loading required package: RcmdrMisc
Loading required package: car
Loading required package: sandwich
Error : .onLoad failed in loadNamespace() for 'Rcmdr', details:
call: structure(.External(.C_dotTclObjv, objv), class = "tclObj")
error: [tcl] invalid command name "tk_messageBox".
In addition: Warning message:
In fun(libname, pkgname) : couldn't connect to display ":0"
Error: package or namespace load failed for ‘Rcmdr’
I have already installed X11 and it still doesn't work.
I had this same issue-- but it ended up working fine as long as I had X11 running prior to opening R. Now it works fine. See if that works!

Resources