jython zxJDBC UCanAccess Driver Class?

188 views Asked by At

Trying to get the combo jython-zxJDBC-UCanAccess working on my Windows machine; been driving me nuts the entire day as I keep getting

zxJDBC.DatabaseError ( driver [net.ucanaccess.jdbc.UcanaccessDriver] not found ), and zxJDBC.DatabaseError ( driver [ucanaccess] not found )

I had been using this sample code from Gord Thompson with my particulars - keeps failing with driver-not-found errors whatever I try:

from com.ziclix.python.sql import zxJDBC
#Or also import ucanaccess

jdbc_url = "jdbc:ucanaccess://Z:/Companies.accdb"
username = ""
password = ""
driver_class = "net.ucanaccess.jdbc.UcanaccessDriver"
#Or driver_class = "net.ucanaccess.jdbc.UcanloadDriver"

cnxn = zxJDBC.connect(jdbc_url, username, password, driver_class)
crsr = cnxn.cursor()
crsr.execute("SELECT * FROM tblSICs")
for row in crsr.fetchall():
    print row[0]
crsr.close()
cnxn.close()
  • Jython alone works well, I use it with the SikuliX IDE
  • 'from ... import zxJDBC' passes without error
  • UCanAccess works fine from the command line (console.bat) with my MS Access database; all 5 JARs are in and as in the CLASSPATH variable

What I don't get is what is "driver_class"?. I thought that the database-specific driver gets located by means of Jython/SikuliX looking in CLASSPATH, where the '.../ucanaccess-5.0.0.jar' is seen.

Here the CLASSPATH:

"c:\Users\User\AppData\Roaming\UCanAccess\lib\hsqldb-2.5.0.jar;c:\Users\User\AppData\Roaming\UCanAccess\lib\jackcess-3.0.1.jar;c:\Users\User\AppData\Roaming\UCanAccess\lib\commons-lang3-3.8.1.jar;c:\Users\User\AppData\Roaming\UCanAccess\lib\commons-logging
-1.2.jar;c:\Users\User\AppData\Roaming\UCanAccess\ucanaccess-5.0.0.jar"

And here is where the SikuliX IDE looks for resources:

D:\Drawer 3\Sikuli\Training\UCanAccess.sikuli Z:\test.sikuli C:\Users\User\AppData\Roaming\Sikulix\Lib\site-packages C:\Users\User\AppData\Roaming\Sikulix\Lib C:\Users\User\AppData\Roaming\Sikulix\Extensions\Lib C:\Users\User\AppData\Roaming\Sikulix\Extensions\jython-standalone-2.7.2.jar\Lib classpath pyclasspath/

Does anyone spot the issue?

1

There are 1 answers

0
Woody Chan On

Issue was found to be a special twist of SikuliX 2.0.4 which cannot evaluate the CLASSPATH variable. Here the workarounds / SiluliX' way to get to know the location of JARs:

Two Solutions:

Solution A

SikuliX IDE looks into the folder <C:\Users\User\AppData\Roaming\Sikulix\Extensions>; all five relevant JAR files need to be places in that folder (no 'lib' subfolder as in the deployment pack):

  • ucanaccess-5.0.0.jar

  • commons-lang3-3.8.1.jar

  • commons-logging-1.2.jar

  • hsqldb-2.5.0.jar

  • jackcess-3.0.1.jar

Check the extension JARs that get found by seeing SikuliX->Tools->Extensions...

Solution B

Leave the needed JARs in their original deployment folder, and add their path to the 'Special File' 'C:\Users\User\AppData\Roaming\Sikulix\Extensions\extensions.txt' as:

  • ucanaccess = C:/Users/User/AppData/Roaming/UCanAccess/ucanaccess-5.0.0.jar

  • C:/Users/User/AppData/Roaming/UCanAccess/lib/commons-lang3-3.8.1.jar

  • C:/Users/User/AppData/Roaming/UCanAccess/lib/commons-logging-1.2.jar

  • C:/Users/User/AppData/Roaming/UCanAccess/lib/hsqldb-2.5.0.jar

  • C:/Users/User/AppData/Roaming/UCanAccess/lib/jackcess-3.0.1.jar

This will be evaluated, as a workaround, instead of the CLASSPATH variable

Thanks for your help!