Reputation: 440
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?
Upvotes: 3
Views: 1988
Reputation: 54342
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(...)
Upvotes: 4