software:db2:start
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
software:db2:start [2017/03/29 09:55] – seela | software:db2:start [2017/03/29 11:23] (current) – seela | ||
---|---|---|---|
Line 153: | Line 153: | ||
to be released upon the world as such!) In the real world, you have to look up | to be released upon the world as such!) In the real world, you have to look up | ||
everything yourself. So be self-reliant. Go to the documentation when you need to. | everything yourself. So be self-reliant. Go to the documentation when you need to. | ||
- | |||
</ | </ | ||
+ | \\ | ||
+ | =====How to find the JCC Version ===== | ||
+ | \\ | ||
+ | **How to find out the JCC driver version being used in your application** \\ | ||
+ | \\ | ||
+ | < | ||
+ | % db2jcc -version | ||
+ | red 278 % source ~db2leduc/ | ||
+ | red 280 % db2jcc -version | ||
+ | IBM Data Server Driver for JDBC and SQLJ 4.22.29 | ||
+ | Alternatively | ||
+ | |||
+ | % java com.ibm.db2.jcc.DB2Jcc -version | ||
+ | IBM Data Server Driver for JDBC and SQLJ 4.22.29 \\ | ||
+ | \\ | ||
+ | % / | ||
+ | | ||
+ | IBM DB2 JDBC Universal Driver Architecture 3.72.24 | ||
+ | \\ | ||
+ | </ | ||
+ | **How to display the version of the Universal Driver** | ||
+ | \\ | ||
+ | < | ||
+ | % / | ||
+ | Returns \\ | ||
+ | IBM Data Server Driver for JDBC and SQLJ 4.22.29 | ||
+ | \\ | ||
+ | </ | ||
+ | ====Technote==== | ||
+ | \\ | ||
+ | Question | ||
+ | |||
+ | Which JDBC driver (JCC) version corresponds with each DB2 release and Fix Pack level? | ||
+ | Answer | ||
+ | |||
+ | The IBM Data Server Driver for JDBC and SQLJ package includes two JDBC drivers: | ||
+ | |||
+ | db2jcc.jar - This driver is based on the JDBC 3 specification | ||
+ | db2jcc4.jar - This driver is based on the JDBC 4 or later specifications | ||
+ | |||
+ | The db2jcc.jar driver is now deprecated. After version 3.72, which is delivered with DB2 Version 11.1 for Linux, UNIX, and Windows Modification Pack 1 Fix Pack 1, db2jcc.jar will include no new features | ||
+ | |||
+ | |||
+ | =====JDBC and SQL Drivers ===== | ||
+ | \\ | ||
+ | **JDBC Drivers** | ||
+ | \\ | ||
+ | |||
+ | For the **DB2 JDBC Type 4 Driver**, specify a URL of the following form: | ||
+ | TYPE 4: | ||
+ | Connecting to a data source using the DriverManager interface with the IBM Data Server Driver for JDBC and SQLJ | ||
+ | |||
+ | A JDBC application can establish a connection to a data source using the JDBC DriverManager interface, which is part of the java.sql package. | ||
+ | < | ||
+ | The steps for establishing a connection are: | ||
+ | |||
+ | Load the JDBC driver by invoking the Class.forName method. | ||
+ | If you are using JDBC 4.0 or later, you do not need to explicitly load the JDBC driver. | ||
+ | For IBM Data Server Driver for JDBC and SQLJ, you load the driver by invoking the Class.forName method with the following argument: | ||
+ | |||
+ | com.ibm.db2.jcc.DB2Driver | ||
+ | |||
+ | The following code demonstrates loading the IBM Data Server Driver for JDBC and SQLJ: | ||
+ | |||
+ | try { | ||
+ | // Load the IBM Data Server Driver for JDBC and SQLJ with DriverManager | ||
+ | Class.forName(" | ||
+ | } catch (ClassNotFoundException e) { | ||
+ | | ||
+ | } | ||
+ | |||
+ | |||
+ | </ | ||
+ | |||
+ | ====A Sample JDBC Program with type 4 connectivity==== | ||
+ | \\ | ||
+ | | ||
+ | |||
+ | \\ | ||
+ | Once downloaded , rename the file to EzSailor.java | ||
+ | \\ | ||
+ | Edit the java source file to modify the database and tables you have created | ||
+ | \\ | ||
+ | {{: | ||
+ | \\ | ||
+ | Must be renamed to EzJava.java and edited to make the right connection | ||
+ | \\ | ||
+ | **How to execute the jdbc program** | ||
+ | \\ | ||
+ | Make sure you have the table " | ||
+ | be able to execute | ||
+ | |||
+ | * source the client configuration file : ~db2leduc/ | ||
+ | * javac EzSailor.java | ||
+ | * java EzJava c3421m | ||
+ | ---- | ||
+ | \\ | ||
+ | |||
+ | ====A Sample Sqlj Program with type 4 connectivity==== | ||
+ | **How to execute the sqlj code** | ||
+ | \\ | ||
+ | * Download the sample code | ||
+ | * Table " | ||
+ | {{: | ||
+ | \\ | ||
+ | This is a sample sqlj program that does the precompiling for you . | ||
+ | Remember these are just example scripts to aid the development of your own code | ||
+ | \\ | ||
+ | \\ | ||
+ | * Program name : sailor.sqlj | ||
+ | * source ~db2leduc/ | ||
+ | * sqlj sailors.sqlj | ||
+ | * db2sqljcustomize -url jdbc: | ||
+ | * java sailors 71 | ||
+ | will return your output | ||
+ | |||
+ | |||
\\ | \\ | ||
software/db2/start.1490795715.txt.gz · Last modified: 2017/03/29 09:55 by seela