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.
Below is i simple code that i've alredy write it but have an error
#odbc.py
from java.sql import *
class connection(Driver):
def __init__(self,url,username,password):
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()
>>> from odbc import connection
>>>p=connection('Test','sa','password')
Traceback (innermost last):
File "<console>", line 1, in?
FIle "C:\jython\jython-2.0a1\odbc.py" line 5 in?
Name Error: Class
|