I am attempting to connect to an Access database using RJDBC. I have installed Java, RJDBC, and the JDBC Access drivers (I'm not sure which one of them is needed and would prefer that one be selected automatically, if possible). My attempts to make a connection based on examples in the documentation have so far been unsuccessful, so I'm clearly missing something.
Here's some system information that might be relevant:
% java -version
openjdk version "21.0.1" 2023-10-17
OpenJDK Runtime Environment Homebrew (build 21.0.1)
OpenJDK 64-Bit Server VM Homebrew (build 21.0.1, mixed mode, sharing)
% ls /Library/Java/Extensions/AccessJdbcDriver
commons-lang3-3.8.1.jar hsqldb-2.5.0.jar ucanaccess-5.0.1.jar
commons-logging-1.2.jar jackcess-3.0.1.jar
I'm not sure which of those drivers I need, but when I connect to the database with the separate application DbSchema, it appears that it is using ucanaccess-5.0.1.jar, which I think has the class name net.ucanaccess.jdbc.UcanaccessDriver, but I'm not sure that's actually the case.
The man page gives three ways to specify a driver, and says the second is very unreliable, so just trying 1 and 3...
- Specify full name of driver class and path. (I'm not positive about the name.)
drv <- RJDBC::JDBC("net.ucanaccess.jdbc.UcanaccessDriver", "/Library/Java/Extensions/AccessJdbcDriver/ucanaccess-5.0.1.jar")
#> Error in RJDBC::JDBC("net.ucanaccess.jdbc.UcanaccessDriver", "/Library/Java/Extensions/AccessJdbcDriver/ucanaccess-5.0.1.jar"): java.lang.NoClassDefFoundError: com/healthmarketscience/jackcess/util/ErrorHandler
I'm not sure what to do about the "no class definition error" here.
- Use
findDrivers()
drv <- RJDBC::JDBC(RJDBC::findDrivers(classPath = "/Library/Java/Extensions/AccessJdbcDriver/ucanaccess-5.0.1.jar"))
#> Error in .jcall("java.util.ServiceLoader", "Ljava/util/ServiceLoader;", : java.util.ServiceConfigurationError: java.sql.Driver: no caller to check if it declares `uses`
Again, I'm not understanding anything useful from the error message. Any guidance will be appreciated.