Reputation: 57
I'd like to connect to my SQL Server DB using zxJDBC, but I can't figure out which driver to use... My function looks like so:
def sqlServerConnect():
conn = 'jdbc:sqlserver://MYDB'
username = "username"
password = "password"
driver = "com.microsoft.sqlserver.jdbc.SQLServerDriver"
try:
conn = zxJDBC.connect(jdbc_url, username, password, driver)
print "Connection successful"
except zxJDBC.DatabaseError, e:
print "Connection failed:", e
The error message reads as follows:
Connection failed: driver [com.microsoft.sqlserver.jdbc.SQLServerDriver] not found
Upvotes: 1
Views: 1193
Reputation: 57
I found a solution, which is to use Jython's -J
switch to give the JVM (Java Virtual Machine) a -cp
classpath argument with the location of the JDBC jar file, e.g.,
jython -J-cp sqljdbc4.jar myProgram.py
Upvotes: 2