简体   繁体   English

RJDBC,与 Oracle 数据库的 Java 连接崩溃

[英]RJDBC, Java connection to Oracle database crashing

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.我有一个脚本,用一些代码打开以启动与 Oracle 数据库的连接,但是该代码在运行后立即使 RStudio 崩溃。 The exact code was run successfully on another machine previously.确切的代码之前在另一台机器上成功运行。

The script opens by loading the required RJDBC package:该脚本通过加载所需的 RJDBC 包打开:

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."但是这会导致 Rstudio 崩溃 - 没有错误声明,程序只是崩溃,指出“R 遇到致命错误。会话已终止。” When I attempt run this at the command line in regular R (not RStudio) it crashes also.当我尝试在常规 R(不是 RStudio)的命令行中运行它时,它也会崩溃。

If this is being caused by some conflict between R and machine, is there a way to determine what is causing it?如果这是由 R 和机器之间的某些冲突引起的,有没有办法确定是什么原因引起的?

Thanks谢谢

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).我遇到了完全相同的问题,刚刚将我的 Java 发行版从 v6 升级到 v8(Java 运行时和 Java 开发工具包,在 Windows 7 上运行)。 I don't what the reason is, but after reinstalling v6 (and keeping v8), the problem was resolved.我不知道是什么原因,但在重新安装 v6(并保留 v8)后,问题解决了。

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. In 也遇到了这个问题,但在我的情况下,问题是我之前在 ~/.Renviron 中设置了 JAVA_HOME 与安装 rJava 时的版本不匹配。 Simply removing JAVA_HOME was the fix in my case.在我的情况下,只需删除 JAVA_HOME 即可解决。

I was also experiencing the same sort of crash trying to connect to SQL Server.我在尝试连接到 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:按照https://www.r-bloggers.com/connecting-r-to-an-oracle-database-with-rjdbc/所述设置 JAVA_HOME 变量,崩溃消失了:

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")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM