In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article will explain in detail how to achieve Jython installation and how to use JDBC drivers to connect to DB2. The editor thinks it is very practical, so I share it with you for reference. I hope you can get something after reading this article.
Installation of Jython
To run the examples in this article, you need to install Jython 2.1and JVM. You can get Jython from the Jython home page. Installation is convenient if you add the Jython installation path to the PATH environment variable on the platform.
Enable the SAMPLE database in DB2 UDB V8
The example shown in this article uses the SAMPLE database. You can create an SAMPLE database either by running the db2sampl program released with DB2 or from FirstSteps in the DB2 installation tools menu. In addition, a DB2 ID/ password must be created. In this article, we use vyang/jythonrocks.
How to connect to SAMPLE database in Jython
After Jython is installed and the database is started, we will show how to connect to SAMPLE databases in Jython using the popular type 2 and type 4 JDBC drivers.
Type 2 JDBC driver (CLI JDBC driver)
From java.lang import * from java.sql import * Class.forName ("COM.ibm.db2.jdbc.app.DB2Driver") .newInstance () con = DriverManager.getConnection ('jdbc:db2:sample','vyang','jythonrocks')
Type 4 JDBC driver (new in DB2 UDB V8)
From java.lang import * from java.sql import * Class.forName ("com.ibm.db2.jcc.DB2Driver") .newInstance () con = DriverManager.getConnection ('jdbc:db2://db2host:50000/sample','vyang','jythonrocks')
The above code to connect to the SAMPLE database looks very similar to the JDBC java code, except for the following:
After Jython installation, you need to import every Java package, including java.lang.
Jython strings can use either single or double quotation marks.
The type of Jython is dynamic, so there is no need to declare the type of con as java.sql.Connection.
This is the end of the article on "how to install Jython and connect to DB2 using JDBC drivers". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.