Dear John,

 i“m using Jython scripts based on standard Java JDBC interfaces and
this works well for me. My applications are running under DB2 databases
and i“ve chosen two types of driver implementations:
  A) ODBC based SQL drivers for Windows;
  B) DB2 to JDBC (type 4) drivers for LINUX;      
 The ODBC based driver are also visible to Windows, or you can choose
a JDBC compliant Java driver delivered by the database vendor.    

You will find the available drivers from a download page of MySQL:

For ex. the ODBC<->JDBC driver called "Connector/ODBC" and JDBC Java
driver called "MySQL Connector/J".  Both will do the connectivity.

 Let me copy here some of the Jython statements to illustrate the difference:

Sample for A (JDBC<->ODBC):

from java.sql import *
from import *

# load DB2 JDBC type 2 driver (app driver)
urlstring = "sun.jdbc.odbc.JdbcOdbcDriver"

# setup the properties
prop = Properties()
prop.put("user", username)
prop.put("password", password)

# Load the JDBC-ODBC bridge driver
url = "jdbc:odbc:" + dbname
conn = DriverManager.getConnection(url, prop)
stmt = conn.createStatement()
if stmt.execute(query):
     rowcnt = rs.getInt(1)

Sample for B (DB2 type for 4 drivers):

from java.sql import *
from import *

# load DB2 JDBC type 4 driver (app driver)
# Load the JDBC type 4 driver
url = "jdbc:db2://localhost:60000/" + dbname
conn = DriverManager.getConnection(url,username,password)
stmt = conn.createStatement()
if stmt.execute(query):
     rowcnt = rs.getInt(1)

Have fun with Jython.


Claude Falbriard
AMS Hortolāndia / SP - Brazil
phone: +55 13 8117 3316

"jh" <>
Sent by:

27/06/2007 13:11

[Jython-users] MySQL

I am using a tool called maxq that is written in jython and I want to make
some MySQL queries from my test script. It looks like zxJDBC is available as
the following lines execute OK but complains that the driver was not found.
I picked up the driver name from the jython page The driver name seems a bit unusual
but other examples have multi-dotted names too. I also added
mysql-connector-java-5.0.6-bin to the jar lib and the CLASSPATH and tried
their driver names to no avail.

Don't know much about jython per se but if you have any insight or ideas
about accessing MySQL please sing out.




from com.ziclix.python.sql import zxJDBC
       d, u, p, v = "jdbc:mysql://localhost", 'admin', 'myPassword',
       db = zxJDBC.connect(d, u, p, v)

This email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
Jython-users mailing list