Build stronger Java Support

Source: Internet
Author: User
Tags db2 requires savepoint linux

Enhancements to DB2 JDBC Universal Driver in the DB2 UDB v.8.2 allow developers to enjoy amazing performance and manageability.

DB2 Universal Database (UDB) version 8.2 on Linux, Unix, and Windows platforms supports many types of Java programs, including stored procedures used in client applications, application servers, and DB2 UDB servers or user-defined functions in both of these forms.

IBM introduced the DB2 Universal JDBC Driver to support JDBC and v.8.1 in DB2 UDB SQLJ (embedded SQL for Java applications) programming technology. In the DB2 UDB v.8.2, this driver includes full support for distributed transactions, the JDBC 3.0 API, and the serviceability and performance enhancements that are specific to the driver.

The new JDBC features in DB2 v.8.2 include enhanced result set processing (which preserves cursor support) and savepoint (savepoint). In v.8.2, Java application monitoring is largely simplified because of a new SQL function that can obtain DB2 UDB for Linux, Unix, and Windows server performance information.

We'll show you how to start using this new JDBC driver, how to get DB2 UDB server information features in Java applications, and how to build Java applications for DB2 in an open source development environment Eclipse.

The DB2 UDB v.8.2 includes support for many of the new JDBC 3.0 features that we cannot elaborate on in this one by one. For more information about Java support for DB2 UDB v.8.2, see "Do More with" and page 51st of resources on page 32nd.

Universal JDBC Driver

The latest Java programming specification is defined by the Java 2 Platform Enterprise Edition (EE) 1.4, which requires a JDBC 3.0-compliant driver to access the RDBMS in a variety of java-based program modules. These modules may be on the client workstation or in the application server.

The DB2 Universal JDBC driver includes support for connections of type 4 and type 2 modes. Before you choose a DB2 JDBC connection mode, you need to analyze your development and running environment. Most users prefer the "Type 4" driver because it can be provided directly with the application without having to rely on shared libraries. The Type 2 driver always requires a shared library, because the communication between the driver and the server is handled by a non-Java component of the driver. Based on experience, you should use type 4 if you want to access the database remotely via TCP/IP, or you should use type 2 if you are in the same logical operating system as the DB2 server (IPC) or in a Java stored procedure (You cannot use TCP/IP to access DB2).

Building Connections through Java

When using DB2 Universal JDBC Driver with Linux, Unix, and DB2 UDB on Windows, you must ensure that TCP/IP connectivity is supported on the DB2 UDB server. To ensure that the DB2 UDB server instance can receive database access requests from Java applications, you need to perform two steps:

1. db2set DB2COMM=TCPIP
2. db2 update dbm cfg using SVCENAME <tcp/ip service name>

These two items should be set correctly during the DB2 UDB server installation. However, if there is a problem establishing the initial connection to the DB2 UDB server, you should first check both settings. The SVCENAME should correspond to the ports defined in the service file on the computer where the DB2 UDB server resides.

As you may know, JDBC is a dynamic SQL interface defined by the Java 2 Standard Edition (J2SE) specification for DB2. The Java language includes many built-in classes and interfaces, but does not provide a JDBC driver for DB2 UDB servers. Therefore, the application needs to mount a set of classes and interfaces that understand how to interact with the DB2 UDB server. The following line of Java code will use the Db2driver interface to accomplish this task:

Class.forName("com.ibm.db2.jcc.DB2Driver")

After the driver has been successfully loaded, you can use the Drivermanager.getconnection method to connect to the DB2 UDB server, which is configured by the Java property embedded in the URL, or included in the getconnection () method, or it is provided in an external property file. You can also use a configurable JDBC 2 data source instance instead of DriverManager to establish a connection.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.