2

I have a script that opens with some code to start a connection to an Oracle database, however the code is crashing RStudio as soon as it runs. The exact code was run successfully on another machine previously.

The script opens by loading the required RJDBC package:

library("RJDBC", lib.loc="C:/R/library")

After, this I run the code below:

drv = JDBC("oracle.jdbc.OracleDriver", classPath="C:/R/ojdbc7.jar", identifier.quote = " ")

however this crashes Rstudio - there is no error statement, the program simply crashes stating that "R encountered a fatal error . The session was terminated." When I attempt run this at the command line in regular R (not RStudio) it crashes also.

If this is being caused by some conflict between R and machine, is there a way to determine what is causing it?

Thanks

Qaribbean
  • 178
  • 2
  • 3
  • 17
  • Try a clean R Studio session, deleting any .Rhistory or .RData. Also, check by running script at command line: `Rscript c:/path/to/script.R` where possibly a specific error will eventually raise. – Parfait Jul 29 '16 at 22:31
  • Also, is there a reason why your `identifier.quote` argument is a space? `NA` is the default. Oracle I believe uses double quotes for identifiers, try escaping with backslash: `\"`? – Parfait Jul 29 '16 at 22:34
  • I have been running with a clean session, before loading the libraries I have a line clearing the workspace and I also clear the history. My colleague is running the exact same code on another machine without crashing on that line. Also when I run the script in regular R (not Rstudio), this is also crashing immediately after running the line! – Qaribbean Aug 04 '16 at 10:23

3 Answers3

2

I had exactly the same problem, having just upgraded my Java distribution from v6 to v8 (both Java Runtime and Java Developer Kit, running on Windows 7). I don't what the reason is, but after reinstalling v6 (and keeping v8), the problem was resolved.

Niamh_OC
  • 36
  • 4
  • Thank you very much! I have V8 - I downloaded V6 (Runtime and Developer Kit) and after restarting I have attempted to run the code and it has worked. Would like to know why there is a conflict with V8 and R, perhaps we'll find out some day! Thanks again! – Qaribbean Sep 27 '16 at 15:52
1

In also encountered this problem but in my case the issue was that I had previously set JAVA_HOME in ~/.Renviron that did not match the version in place when rJava was installed. Simply removing JAVA_HOME was the fix in my case.

Andrew Kirk
  • 1,774
  • 1
  • 14
  • 16
0

I was also experiencing the same sort of crash trying to connect to SQL Server.

Setting the JAVA_HOME variable as described https://www.r-bloggers.com/connecting-r-to-an-oracle-database-with-rjdbc/ the crashes went away:

Sys.setenv(JAVA_HOME='C:/Program Files/Java/jdk1.8.0_172')
library(RJDBC)
drv <- JDBC("com.microsoft.sqlserver.jdbc.SQLServerDriver",
"c:/Microsoft JDBC Driver 6.4 for SQL Server/sqljdbc_6.4/enu/mssql-jdbc-6.4.0.jre8.jar")