MYSQL connection to jython

2010-07-29
2012-09-19
  • Neha Dharni
    Neha Dharni
    2010-07-29

    While I am trying to connect with database through jython, I am getting
    exception "unable to instantiate datasource" in line mysqlConn =
    zxJDBC.connectx(url, user, password, driver,CHARSET='iso_1')

    My piece of code is :

    from com.ziclix.python.sql import zxJDBC

    url = 'jdbc:mysql://localhost/test'

    user = 'test'

    password = 'pass123'

    driver = 'org.gjt.mm.mysql.Driver'

    try:

    mysqlConn = zxJDBC.connectx(url, user, password, driver,CHARSET='iso_1')

    if mysqlConn is not None:

    print "Successfully connected"

    else:

    print "Not able to connect with database"

    except zxJDBC.DatabaseError,err:

    print err

    I have installed mysql-connector-java-5.1.13-bin.jar too and included that in
    my classpath.Any clue why I am getting this error?

     
  • Although you're using it from Python/Jython, you're not actually using the
    MySQLdb driver that exists in this project. You actually want the JDBC driver
    project:

    http://sourceforge.net/projects/mmmysql/