Error connecting SikuliX 2.0.5 to sqlserver using zxJDBC

Asked by Kyle Winmill on 2021-05-19

My team at work has been using this below to successfully connect to our database and execute a query for 5 years now:

load("sqljdbc4-2.0.jar")
from com.ziclix.python.sql import zxJDBC
connection = zxJDBC.connect('jdbc:sqlserver://xxx.xxx.x.xxx', 'xxx', 'xxx','com.microsoft.sqlserver.jdbc.SQLServerDriver')
cursor = connection.cursor()
SQLCommand = importQuery.readFile('C:\\testQuery.sql')
cursor.execute(SQLCommand)
result = list(cursor)
connection.commit()
connection.close()

After this, we then loop through each row and execute tests based off of the results that we get from our query.

This has never worked with SikuliIDE-2.0.0 or later, and we haven't been able to get it to connect with the new versions, so we stuck with 1.1.2 as we had the least issues with that version. With the latest Java update we are no longer able to use the older versions and want to update to the latest version of Sikuli, 2.0.5.

When I run in 2.0.5, I get the following error on the second line (from com.ziclix.python.sql import zxJDBC):

[error] script [ 1389693genExY&YTforWorksheetOnlyRerunInY ] stopped with error in line 56
[error] java.lang.NoClassDefFoundError ( java.lang.NoClassDefFoundError: Could not initialize class com.ziclix.python.sql.zxJDBC )
[error] --- Traceback --- error source first
line: module ( function ) statement
56: main ( <module> ) from com.ziclix.python.sql import zxJDBC
[error] --- Traceback --- end --------------

We have tried updating the jdbc jar to mssql-jdbc-9.2.1.jre15.jar, and changed our first line to reference that, with just the name of it and with putting in the full path before it (although it used to always work without the path, just with load("sqljdbc4-2.0.jar"), but without success.

We also tried following the solution from https://answers.launchpad.net/sikuli/+question/242975 without success.

Any help would be greatly appreciated!

Question information

Language:
English Edit question
Status:
Answered
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
RaiMan (raimund-hocke) said :
#1

Sorry, but with 2.0.5 the load() feature does not work anymore as expected, since entries to the Java class path from inside a Java program are no longer allowed.

You have to setup the Java class path and IDE start on the command line for example like so:

java -cp mystuff1.jar;mystuff2.jar;<sikulix-ide-jar> org.sikuli.ide.Sikulix ... optional parameters ...

Can you help with this problem?

Provide an answer of your own, or ask Kyle Winmill for more information if necessary.

To post a message you must log in.