From: <bc...@wo...> - 2000-11-28 09:29:30
|
[irwan] >I've already download jython-2.0a1 and successfully installed to my computer. >I would like to make a databse connection using java sql module. Do you >have any reference that i can use it. The zxJDBC module from http://www.ziclix.com/ may be usefull to you. >Below is i simple code that i've alredy write it but have an error I made a few changes; now the program will at least try to open the Test data through odbc. I do not have such a database on my PC so I have not tested the program further than that. regards, finn from java.sql import * import java class connection(Driver): def __init__(self,url,username,password): java.lang.Class.forName("sun.jdbc.odbc.JdbcOdbcDriver") self.db=DriverManager.getConnection(url,username,password) self.st=self.db.createStatement() print "Database Connected" rs=st.executeQuery("select * from acount_t") try: if rs.next(): str='%s' % rs.getString(1) print str except: print "Error" self.st.close() self.db.close() p=connection('jdbc:odbc:Test','sa','password') |