How to access MySQL database?

Asked by Raymond

I want my Sikuli app to be able to connect to a MySQL database. What options do I have?

I did a search for "jython mysql" on Google and turned up a an sql module from the java module. I'm not sure if it exists and if it does why it isn't working.

I was told to do this to import and invoke the sql connector, but it's throwing a "Class not defined" error so I'm not sure if the java module even has sql capability. The code I ran was this:

from java.lang import *
from java.sql import *
driverName="com.mysql.jdbc.Driver"
Class.forName(driverName)

From the Sikuli interpreter I got this:

"NameError: name 'Class' is not defined"

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
Revision history for this message
Shimano (shimdal) said :
#2

try

from java.lang import *
from java.lang import Class
from java.sql import *
Class.forName("com.mysql.jdbc.Driver")

now I got
java.lang.ClassNotFoundException: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver

I have mysql-connector-java-5.1.10.jar but it not seem to load in Sikuli environnement.

Any idea or setting to check?

Revision history for this message
Paul Bellamy (pbellamy) said :
#3

Hi Raymond,

I was troubleshooting a similar issue and stumbled upon this, which helped greatly (see the "classpathHacker" section):

http://jythonpodcast.hostjava.net/jythonbook/en/1.0/appendixB.html#working-with-classpath

Revision history for this message
Peter Spierenburg (peter-spierenburg) said :
#4

This link appears to be broken. I could really use a solution to this problem.

Revision history for this message
Keiron (keiron) said :
#5

Can you help with this problem?

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

To post a message you must log in.