← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #202408]: using jdbc driver in Sikuli script

 

Question #202408 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/202408

RaiMan proposed the following answer:
I made some tests with Sikuli and Jython 2.5.3 running them in there
default configuration from command line

Whatever you do, you get the message:
zxJDBC.DatabaseError: driver [.....Driver] not found

when using the mysql driver
mysql-connector-java-5.1.21-bin.jar

The problem seems to be, that the driver is named <
com.mysql.jdbc.Driver > and a com directory is in the Jython internal
Lib directory, that comes before the __classpath__ reference in
sys.path. So Jython tries to find the mysql.dbc.Driver in this internal
Lib/com directory (where it is not ;-).

Running a sikuli script this way, works with a standalone Jython (need
not be installed, just downloaded and unzipped):

-- a bash script
cp=<some-folder>//mysql-connector-java-5.1.21/mysql-connector-java-5.1.21-bin.jar
cp=$cp:<some-other-folder>/jython.jar
java -cp $cp org.python.util.jython $1.sikuli/$1.py

the <..folder> have to be adjusted to your situation.
This brings < com.mysql.jdbc.Driver > into the first place and it is found.

If you exchange the jython.jar by sikuli-script.jar it works too.

In any case you need an 
from sikuli import *
at the beginning of your script, if you want to use Sikuli features.

--- the test script:
MySQLDriver = 'com.mysql.jdbc.Driver'
from com.ziclix.python.sql import zxJDBC
jdbc_url = 'jdbc:mysql://localhost:3306/BinckAutoTest'
username = 'root'
password = 'password'
urldb = zxJDBC.connect(jdbc_url, None, None, MySQLDriver)

--- the printout:
Traceback (most recent call last):
  File "jython.sikuli/jython.py", line 13, in <module>
    urldb = zxJDBC.connect(jdbc_url, None, None, MySQLDriver)
zxJDBC.DatabaseError: Communications link failure

The last packet sent successfully to the server was 0 milliseconds ago.
The driver has not received any packets from the server. [SQLCode: 0],
[SQLState: 08S01]

You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.