1

Currently trying to use the JayDeBeApi pkg with Ucanaccess drivers to read an .accdb file on Databricks. I am placing the .accdb file in the DBFS and trying to read from there.

I am currently using Databricks Community Edition to build a proof of concept to avoid certain restrictions in a work environment.

The below code presents the error:

net.ucanaccess.jdbc.UcanaccessSQLException: UCAExc:::5.0.1 given file does not exist:

import jaydebeapi, jpype
 
connectionProperties = {
  "driver" : "net.ucanaccess.jdbc.UcanaccessDriver"
}
 
url = "jdbc:ucanaccess://dbfs/FileStore/tables/ASampleDatabase.accdb"
df = spark.read.jdbc(url=url, table="Asset Items", properties=connectionProperties)

This code presents the error:

TypeError: Class net.ucanaccess.jdbc.UcanaccessDriver is not found

import  jaydebeapi, jpype
 
# Initiate Java runtiome file location 
 
ucanaccess_jars = [
        "dbfs:/FileStore/jars/UCanAccess-5.0.1.bin/ucanaccess_5_0_1.jar",
        "dbfs:/FileStore/jars/UCanAccess-5.0.1.bin/lib/commons_lang3_3_8_1.jar",
        "dbfs:/FileStore/jars/UCanAccess-5.0.1.bin/lib/commons_logging_1_2.jar",
        "dbfs:/FileStore/jars/UCanAccess-5.0.1.bin/lib/hsqldb_2_5_0.jar",
        "dbfs:/FileStore/jars/UCanAccess-5.0.1.bin/lib/jackcess_3_0_1.jar",
        ]
 
# classpath = $PATH$ parameters for Java runtime file location
 
classpath = ":".join(ucanaccess_jars)
 
# Initate connection to MS Access files
cnxn = jaydebeapi.connect(
    "net.ucanaccess.jdbc.UcanaccessDriver",
    "jdbc:ucanaccess:///FileStore/tables/ASampleDatabase.accdb",#.accdb file
  
    ["", ""],
    classpath
    )
 
# From connection initiate cursor
crsr = cnxn.cursor()
 
# Run Query
crsr.execute("SELECT * FROM 'Asset Items'")
 
# Fetch Query result
for row in crsr.fetchall():
    print(row)
 
# Close cursor
crsr.close()
# Close connection
cnxn.close()

Regarding the file path I have tried 3 slashes, 2 slashes. with colon without colon. I think I have tried every possible combination for the filepath with no success as that has been mentioned in other posts as a potential issue.

0 Answers0