I'm trying to make a JDBC connection to Sybase IQ in the R language. One of the first steps appears to be to create a new DBI driver. To do this, I need the driver class, the class Path, and the quote identifier. I've used two options below that have ended up crashing R:
I'm not sure what I'm specifying incorrectly. Any suggestions are appreciated. Below is some of the documentation from R, which may be helpful: JDBC engineDescriptionJDBC creates a new DBI driver that can be used to start JDBC connections. UsageJDBC (driverClass = "", classPath = "", identifier.quote = NA) ArgumentsdriverClass classPath identifier.quote DetailsJDBC function has two purposes. One is to initialize the Java VM and load a Java JDBC driver (not to be confused with the JDBCDriver R object which is actually a DBI driver). The second purpose is to create a proxy R object which can be used to a call dbConnect which actually creates a connection. JDBC requires a JDBC driver for a database-backend to be loaded. Usually a JDBC driver is supplied in a Java Archive (jar) file. The path to such a file can be specified in classPath. The driver itself has a Java class name that is used to load the driver (for example the MySQL driver uses com.mysql.jdbc.Driver), this has to be specified in driverClass. Due to the fact that JDBC can talk to a wide variety of databases, the SQL dialect understood by the database is not known in advance. Therefore the RJDBC implementation tries to adhere to the SQL92 standard, but not all databases are compliant. This affects mainly functions such as dbWriteTable that have to automatically generate SQL code. One major ability is the support for quoted identifiers. The SQL92 standard uses double-quotes, but many database engines either don't support it or use other character. The identifier.quote parameter allows you to set the proper quote character for the database used. For example MySQL would require identifier.quote="`". If set to NA, the ability to quote identifiers is disabled, which poses restrictions on the names that can be used for tables and fields. Other functionality is not affected. As of RDJBC 0.2-2 JDBC-specific stored procedure calls starting with {call and {?= call are supported in the statements. ValueReturns a JDBCDriver object that can be used in calls to dbConnect. Examples
|
The driver class for the SQL Anywhere JDBC driver (sajdbc4.jar) is: sap.jdbc4.sqlanywhere.IDriver. The driver class for jConnect driver (jconn4.jar) is com.sybase.jdbc4.jdbc.SybDriver. Here is sample R code (which assumes you have installed R JDBC) for Windows. Provide the full path to the jar for your specific OS/setup. Also note, you will need to source the IQ environment so that it is visible to the R development environment when using the SQL Anywhere JDBC driver as it has dependencies on native libraries. SQL Anywhere JDBC Driver require(RJDBC) drv <- JDBC( "sap.jdbc4.sqlanywhere.IDriver", "c:/sa/sa17/java/sajdbc4.jar" ) conn <- dbConnect(drv, "jdbc:sqlanywhere:eng=demo17;dbn=demo", "dba", "sql") jConnect JDBC Driver require(RJDBC) drv <- JDBC( "com.sybase.jdbc4.jdbc.SybDriver", "c:/sa/sa17/java/jconn4.jar" ) conn <- dbConnect(drv, "jdbc:sybase:Tds:localhost:2638", "dba", "sql") If you continue to have problems, please include the specific errors that you are seeing. Thank you, Chris. Here is the error for the SQL Anywhere JDBC Driver
Here is the (same) error for the jConnect JDBC Driver
I'm using a Red Hat Linux platform. Here's the top few lines of the sessionInfo() function:
Here is the Java version information:
I received the same errors using either the Java Development Kit or the Java Runtime Environment as Java Home:
In case this is related to some environmental variable settings, I've listed the output from the Sys.getenv() function below:
Please let me know if there's anything else I can provide, and thank you for taking a look!
(30 Apr '21, 10:10)
Ted M
I believe that this suggests a problem with resolving the JRE and in particular the rt.jar. I do not have a lot of *nix experience so I am not sure specifically what that translates to in terms of the environment. The error itself is not specific to R or the SQLA or jConnect JDBC drivers. If you look at the output from Sys.getenv(), I do not see $JAVA_HOME defined nor $JAVA_HOME/bin in the path.
(30 Apr '21, 20:19)
Chris Keating
Thank you for the feedback. I made additions to the .Renviron file so that Sys.getenv() shows the $JAVA_HOME, $PATH, and $CLASSPATH. Unfortunately, this made no difference. I'll try to reach out to a more general forum regarding Java to see if I can get assistance. Thanks again.
(03 May '21, 10:03)
Ted M
2
If someone needs to follow this thread, please see https://github.com/s-u/rJava/issues/263 .
(03 May '21, 11:59)
Ted M
|