In addition to the self-serving opportunity of me learning Jython, Jython can reuse the same JDBC drivers that TDW uses. So there is no need to setup Perl DBI or database client. We could write the code in Java, but that's an overkill because of compilation requirements. Setting up Jython is very easy. Please refer to this page for detailed installation steps.
Here is the sample code. Just be sure to change the connection settings.
Note: Do NOT cut-paste the code from below listing. Jython, like python, is sensitive to tabs. So, download the code by clicking here.
from com.ziclix.python.sql import zxJDBC
conn = "jdbc:db2://server:50000/warehous"
user = "user"
passwd = "passwd"
driver = "com.ibm.db2.jcc.DB2Driver"
db = zxJDBC.connect(conn, user, passwd, driver)
print "Connection successful"
except zxJDBC.DatabaseError, e:
print "Connection failed:", e
Posted by Venkat Saranathan