BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
wthielen
Calcite | Level 5

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!

1 ACCEPTED SOLUTION

Accepted Solutions
FriedEgg
SAS Employee

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.

View solution in original post

8 REPLIES 8
Ksharp
Super User

As far as I can see , such question should be submitted to sas support.

Technical Support Form

FriedEgg
SAS Employee

Are you trying to perform a SAS/Share or SAS/IOM connection?  Share you connection string and any set properties.

wthielen
Calcite | Level 5

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

ChrisHemedinger
Community Manager

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

It's time to register for SAS Innovate! Join your SAS user peers in Las Vegas on April 16-19 2024.
FriedEgg
SAS Employee

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.

wthielen
Calcite | Level 5

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.

NickMaki
Calcite | Level 5

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

andf
Calcite | Level 5

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!

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 8 replies
  • 2774 views
  • 1 like
  • 6 in conversation