Only difference is that they use the different drivers, driver architectures,Īnd syntax to achieve their connectivity. Good idea to take a look at articles on this topic on the InformIT site.) The We are assuming that you have a background in JDBC. String phoneNumber = resultSet.getString("phonenumber") String name = resultSet.getString("name") cycle through the resulSet and display what was grabbed ResultSet resultSet = st.executeQuery(myQuery) String myQuery = "SELECT * FROM PHONENUMBERS" Statement st = db2Conn.createStatement() use a statement to gather data from the database ![]() Listing 1 Use of the legacy/CLI JDBC driver (db2java.zip), a JDBC-typeĭriver to interact with DB2 import Ĭlass.forName(".app.DB2Driver") Simply retrieve data from the database we created using a simple SQL query. Listing 1, 2, and 3 all do the same thing. Note that the implementation package name isĬom.DB2Driver. The code of Listing 1 shows the programmatic access of the database weĬreated earlier. This can be done using theĬonfiguration Assistant, as shown in Figure 3. Idea to ensure connectivity to your remote database. The JDBC driver to locate the DB2 database on a remote server.īefore you start your endeavors of hooking up to DB2 via Java, it is a good If you are just getting started with DB2 locally on your own machine we wouldįigure 2 shows the DB2 Configuration Assistant (db2ca), it can be used toĬatalog the DB2 database and the node directory information that will be used by License jar file from an existing installation. Really need, you can simply copy the db2jcc.jar file and its corresponding If you decide that the Universal JDBC driver in type 4 mode is all you These clients are downloadable for free atįor Java development, the only required DB2 software is the runtime client,Īnd it is a much smaller download image (around 68MB for Windows and 200MB for Should install the DB2 Application Development Client or the DB2 Runtime Client. If you are connecting to a remote DB2 server, you Installed a DB2 UDB v8 server, you will have the Configuration Assistant and the This driver performs a native connect through a local DB2 client. JDBC driver, you need to use the DB2 Configuration Assistant. ![]() ![]() If you are trying to interact with a remote database using the legacy/CLI The default DB2 installation directory, "c:\Program The legacy/CLI JDBC driver is provided in the file db2java.zip which is in This interaction is illustrated in Figureġ JDBC Type 2 driver implementation: the legacy/CLI JDBC driver. DB2 ships with two different type 2 drivers: the legacy/CLI JDBCĭriver and the universal JDBC driver. JDBC 2 Type 2 drivers use an OS-specific library to facilitate communication DB2 currently offers JDBC drivers known as legacy/CLI drivers and The implementation is known asĪ JDBC driver. Interfaces that implement the JDBC specification. DB2 UDB provides for JDBC connectivity through a number of Java classes and
0 Comments
Leave a Reply. |