安裝(需要已經安裝了jdk/jre?)
Java -jar jython_installer-2.2.1.jar 安裝到C:\jython2.2.1
將zxJDBC.jar解壓縮到c:\tmp
將mm.MySQL-2.0.4-bin.jar復制到c:\tmp
C:\jython2.2.1>set CLASSPATH=c:\tmp\ojdbc5.jar;c:\tmp\zxJDBC.jar;%CLASSPATH%
啟動Oracle服務器
進入jython環境訪問Oracle
編輯文件c:\tmp\ora.py
from oracle.jdbc.driver import OracleDriver
from Java.sql import DriverManager
def connect(un, pw, sid, host, port):
driver = OracleDriver()
DriverManager.registerDriver(driver)
connection = "jdbc:Oracle:thin:@%s:%s:%s" % (host, port, sid)
conn = DriverManager.getConnection(connection, un, pw)
return conn
def DOStuff(conn):
stmt = conn.createStatement()
rset = stmt.executeQuery("SELECT banner FROM sys.v_$version")
while (rset.next()):
print rset.getString(1)
stmt.close()
if __name__ == "__main__":
un = ''ebc20''
pw = ''abc''
sid = ''abc''
host = ''10.4.231.16''
&nbs