3

Hello i'm trying to get a mysql database connection with jython. I'm using Python 3.3.2 and Jython 2.5.3

My code looks like this:

import sys
from java.sql import *
sys.path.append("C:\\dev\\git\\LogAnalysis\\mysql-connector-java-5.0.8.jar")
con = DriveManager.getConnection("jdbc:mysql://localhost:3306/statistik", "root", "admin")
stmt = con.createStatement()
rs = stmt.executeQuery("SELECT * FROM search")

and so on. (Only a code snippet)

Each time i get the exeption:

java.sql.SQLException: java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost:3306/statistik

Can someone give me a tip?

2
  • See here stackoverflow.com/questions/12907260/… Commented Sep 25, 2013 at 11:09
  • Are you sure JDBC driver is in c:\dev\git\...? Also try to add code: from java.lang import Class; Class.forName("com.mysql.jdbc.Driver") Commented Sep 26, 2013 at 8:47

1 Answer 1

4

See solution at: Jython CLASSPATH, sys.path and JDBC drivers

For me the easiest solution is to provide batch/shell script which sets CLASSPATH. This looks like:

SET CLASSPATH=C:\dev\git\LogAnalysis\mysql-connector-java-5.0.8.jar;%CLASSPATH%
CALL jython your_program.py %1 ...

Then you can remove line with:

sys.path.append(...)
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.