Hello,
I posted a question on StackOverflow regarding this, and someone referred me to this site, so I'll post here as well.
StackOverflow: r - Java exception error during RJDBC::dbConnect: how to silently ignore? - Stack Overflow
So as you can read there, I am doing a dbConnect using a JDBC driver (specifically the 94M2 version), within the R environment using RJDBC. However, at the first connect, I get a class not found error for com.sas.net.crypto.CryptoException. My classpath contains sas.core.jar and sas.intrnet.javatools.jar. I can see the CryptoException class in the sas.core.jar though. A second attempt to connect works fine though.
I was wondering two things:
- why would it try to throw a CryptoException? Am I missing some cryptographic libraries?
- why does it not see it in sas.core.jar?,
Thanks!
I believe you are not getting the results you want from .jaddClassPath() because a JVM has not yet been initiated. So, the sas.core.jar is not in the classpath for RJDBC. Try call .jinit() before .jaddClassPath and check what you have by using print(.jclassPath()) if you receive the error again.
As far as I can see , such question should be submitted to sas support.
Are you trying to perform a SAS/Share or SAS/IOM connection? Share you connection string and any set properties.
Thanks for your replies. I am using a jdbc:sharenet:// URL to the WRDS cloud.
The code can be found on my GitHub: wrds/wrds.R at 7edfbfe89ddc329618be72e591cc0bd50e294ea4 · wthielen/wrds · GitHub
You might need to add additional jars into your classpath. Also, SAS may require a specific version of the JRE. I agree that you might want to track this with SAS Tech Support for the best advice, and anything you can do to create a standalone example might be helpful.
Chris
I believe you are not getting the results you want from .jaddClassPath() because a JVM has not yet been initiated. So, the sas.core.jar is not in the classpath for RJDBC. Try call .jinit() before .jaddClassPath and check what you have by using print(.jclassPath()) if you receive the error again.
Thanks, FriedEgg! Adding the .jinit() fixed the issue. If you have a StackOverflow account, please add the same answer there, and I'll accept it as the answer. Otherwise, I'll do it. Please let me know.
Hi,
Is it please possible to describe the steps you used to resolve this problem in more detail.
Specifically, what lines of code should one add in RStudio to resolve this problem?
Thanks
Hello --
Sorry I'm late to the party. This error message can mean one of a few things in the context of an R + RJDBC + rJava --> JDBC --> SAS/SHARE connection, but each centers around an inabiity for the stack to properly find the component drivers.
1. Be sure you have downloaded BOTH required SAS JDBC drivers ( sas.core.jar and sas.intrnet.javatools.jar ) to the same directory on your machine.
2. Be sure you have an .Renviron file that explictly lists both of these files, in appropriate syntax for your platform. Example:
Mac:
CLASSPATH="/Users/my_user/Documents/JDBC_Drivers/sas.core.jar:/Users/my_user/Documents/JDBC_Drivers/sas.intrnet.javatools.jar"
Windows:
CLASSPATH="C:/Users/my_user/Documents/JDBC_Drivers/sas.core.jar;C:/Users/my_user/Documents/JDBC_Drivers/sas.intrnet.javatools.jar"
Note the semicolon delimiter for the Windows version!
3. If you are connecting to WRDS, the .Rprofile code you were given (search the WRDS website for "Using R with WRDS") includes a path to sas.intrnet.javatools.jar. Make sure you update this path to reflect where you have actually placed this driver! It should be the same as in your .Renviron file.
4. If you are using RStudio, be sure that you have placed your .Renviron and .Rprofile files in a location that RStudio knows to look. This directory is controlled by the preference setting General > Default working directory (when not in a project).
Bonus Info! Be sure you are using RJDBC version 0.2-5 or later! Version previous to 0.2-5 experienced a major bug that caused queries resulting in more than 32767 observations to return zero observations instead!
Hope this helps someone!
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.