(c) 2002 International Business Machines Corporation. All rights reserved.
IBM(R) DB2(R) Universal DatabaseTM (UDB) supports all the key Internet standards, making it an ideal database for use on the Web. It has in-memory speed to facilitate Internet searches and complex text matching combined with the scalability and availability characteristics of a relational database. DB2 UDB supports WebSphere(R), JavaTM, and XML technology, which make it easy for you to deploy your e-business applications. DB2 Version 8 also adds self-managing and resource tuning (SMART) database technology to enhance the automation of administration tasks.
DB2 Universal Database supports many types of Java programs. It provides driver support for client applications and applets written in Java using JDBC. It also provides support for embedded SQL for Java (SQLJ), Java user-defined functions (UDFs), and Java stored procedures.
This paper discusses the Java application development environment provided by the DB2 UDB Universal Developer's Edition Version 8 (UDE).
This section describes the following features:
- DB2 JDBC technology
- IBM DB2 JDBC Universal Driver (Type 4 - new in Version 8)
- SQLJ support (new architecture in Version 8)
- Java 2 Platform, Enterprise Edition (J2EE)
According to the JDBC 2 specification, there are four types of JDBC driver architectures:
- Type 1 - drivers that implement the JDBC API as a mapping to another data access API, such as Open Database Connectivity (ODBC). Drivers of this type are generally dependent on a native library, which limits their portability. The JDBC-ODBC Bridge driver is an example of a Type 1 driver.
- Type 2 - drivers that are written partly in the Java programming language and partly in native code. The drivers use a native client library specific to the data source to which they connect. Again, because of the native code, their portability is limited.
- Type 3 - drivers that use a pure Java client and communicate with a middleware server using a database-independent protocol. The middleware server then communicates the client's requests to the data source.
- Type 4 - drivers that are pure Java and implement the network protocol for a specific data source. The client connects directly to the data source.
DB2 Version 8 support Type 2, Type 3 and Type 4 JDBC drivers. The JDBC drivers in previous releases were built on top of DB2 CLI (Call Level Interface). DB2 Version 8 Type 2 and Type 3 drivers continue to use the DB2 CLI interface to communicate to DB2 UDB servers (OS/390® and z/OSTM, UNIX®, Windows®, Linux, and iSeriesTM). DB2 Version 8 adds a new DB2 JDBC Universal Driver (Type 4), which uses the Distributed Relational Database ArchitectureTM (DRDA®) protocol for client/server communications.
DB2 JDBC application driver (Type 2)
The DB2 JDBC application (Type 2) driver ( Figure 1 ) enables Java applications to make calls to DB2 through JDBC. Calls to the JDBC application driver are translated to Java native methods. The Java applications that use this driver must run on a DB2 client, through which JDBC requests flow to the DB2 server. A DB2 ConnectTM Version 8 license/installation is required to access DB2 for OS/390 databases.
Figure 1. DB2 Java Application Architecture

The DB2 JDBC application (Type 2) driver is included in the COM.ibm.db2.jdbc.app package.
JDBC 1 connections The implementation classes for establishing a connection to DB2 UDB servers include:
- COM.ibm.db2.jdbc.app.DB2Driver
JDBC 2 connections The implementation classes for establishing a connection to DB2 UDB servers include:
- COM.ibm.db2.jdbc.DB2ConnectionPoolDataSource
- COM.ibm.db2.jdbc.DB2DataSource
- COM.ibm.db2.jdbc.DB2XADataSource
To configure the application to use the datasource implemented by DB2 JDBC application (Type 2) driver, the following information is required:
databaseName The database name. user The userid used to connect to the database. password The password used to connect to the database.
DB2 thin client driver for JDBC and SQLJ
DB2 UDB Version 8 provides a Type 3 and a Type 4 "thin" driver for JDBC and SQLJ applications. Figure 2 depicts both driver architectures.
Figure 2. DB2 JDBC/SQLj Thin Driver Architecture

The DB2 JDBC Type 3 driver, also known as the applet or net driver, consists of a JDBC client and a JDBC server. The DB2 JDBC applet driver can be loaded by the Web browser along with the applet, or the applet driver can be used in standalone Java applications. When the applet requests a connection to a DB2 database, the applet driver opens a TCP/IP socket to the DB2 JDBC applet server on the machine where the Web server is running.
After a connection is set up, the applet driver sends each of the subsequent database access requests from the applet to the JDBC server through the TCP/IP connection. The JDBC server then makes corresponding DB2 calls to perform the task. Upon completion, the JDBC server sends the results back to the JDBC client through the connection. The JDBC server process is db2jd.
The DB2 JDBC Type 3 driver is included in the COM.ibm.db2.jdbc.net package.
JDBC 1 connections The implementation classes for establishing a connection to DB2 UDB servers include:
- COM.ibm.db2.jdbc.net.DB2Driver
JDBC 2 connections The implementation classes for establishing a connection to DB2 UDB servers include:
- COM.ibm.db2.DB2ConnectionPoolDataSource
- COM.ibm.db2.DB2DataSource
To configure the application to use the datasource implemented by DB2 JDBC Type 3 driver, the following information is required:
databaseName The database name. serverName The server name where the JDBC applet server process resides. portNumber The port number used by the JDBC applet server process (6789 is the default). user The user ID used to connect to the database. password The password used to connect to the database/
There is no Java Transaction API (JTA) support provided by the DB2 JDBC Type 3 driver. JTA provides an interface to accomplish distributed (2-phase commit) transactions.
IBM DB2 JDBC Universal Driver (Type 4 - new in Version 8)
Many new features and enhancements have been made to the JDBC drivers in DB2 Version 8. Among these changes, the biggest change is the architectural improvement that shortens the code path between the JDBC driver and DB2 servers. This new IBM JDBC Universal Driver is based on an open distributed protocol, known as Distributed Relational Database Architecture (DRDA) and is compatible with all DB2 server platforms (UNIX, Windows, Linux, z/OS) with appropriate DRDA Application Server (AS) level support, and prerequisite stored procedures.
Features unique to the new IBM DB2 JDBC Universal Driver include:
- Updateable ResultSet support
- Improved security for DB2 authentication
- Improved Java SQL error information
- Programmatic tracing facilities
To use the JDBC Universal Driver, the db2jcc.jar
must be included in the Java CLASSPATH environment variable.
DB2 JDBC Universal Driver Type 4 driver is included in the
com.ibm.db2.jcc package.
The DB2 UDB Version 8 server will use a TCP/IP connection, specified in the DB2 DBM configuration file (SVCENAME), to communicate with the new DB2 JDBC Universal Driver.
The implementation classes for establishing a connection to DB2 UDB servers include:
- com.ibm.db2.jcc.DB2Driver
Connection objects can be created using the following URL: jdbc:db2://server:port/database
The implementation classes for establishing a connection to DB2 UDB servers include:
- com.ibm.db2.jcc.DB2SimpleDataSource
To configure the application to use the DataSource implemented by DB2 JDBC Universal Driver (Type 4), the following information is required:
databaseName The database name. user The userid used to connect to the database. password The password used to connect to the database. driverType The type of the driver used (4) (required). serverName The TCP/IP address or host name for the DRDA server. portNumber The TCP/IP port number where the DRDA server listens for connection requests to this data source.
Refer to Appendix A for additional DB2 JDBC Universal Driver (Type 4) information.
SQLJ support (new architecture in Version 8)
DB2 SQLJ support enables you to build and run SQLJ applets and applications. These Java programs contain embedded SQL statements that are precompiled and bound to a DB2 UDB database.
The SQLJ standard has three components: a translator,
customizer, and a run-time environment. The translator produces
Java code based on the embedded SQL statements within a source SQLJ
program. A binary representation of the SQL statements is created
in a separate serialized profile ( .ser file). Static
SQL packages are created when the profile is customized using the
db2sqljcustomize command. SQLJ applications require the the
db2jcc.jar file, and SQLJ program preparation also
requires the sqlj.zip file.
Figure 3. SQLJ Application Development

SQLJ provides:
- A static package level security model
- A static SQL interface (e.g.
SELECT xxx INTO :hv1, :hv2) - Increased development productivity as compared to JDBC, especially if an application is being ported from an existing embedded SQL architecture (C, COBOL, etc.)
DB2 Version 8 provides the following SQLJ utilities, as shown in Figure 3.
sqlj
IBM SQLJ Translator. It translates an .sqlj source
file and creates a serialized profile and a program. db2sqljcustomize
Customizer and online checker. It creates a DB2 customization for
the serialized profile, optionally online-checks SQL. statements
that can be dynamically prepared, and optionally (by default) binds
the DB2 packages for this program. db2sqljbind
Standalone binder. It binds a previously customized SQLJ profile to
a database. db2sqljprint Prints
contents of a DB2 customized profile.
The serialized profile that is output from the sqlj translator must be customized before the sqlj program can execute static SQL against DB2 at runtime. Without customization the application will dynamically execute the SQL statements contained in the profile.
Java 2 Platform, Enterprise Edition (J2EE)
Java 2 Platform, Enterprise Edition (J2EE) defines the standard for developing multi-tier enterprise applications. The J2EE platform manages the infrastructure and supports the Web services to enable development of secure, robust and interoperable business applications. J2EE not only takes advantages of many features of the Java 2 Platform, Standard Edition, such as "Write Once, Run Anywhere" portability, JDBC API for database access, but also adds full support for Enterprise JavaBeansTM (EJBs) components, Java Servlets, JavaServer PagesTM (JSPs) and XML technology. With simplicity, portability, scalability and legacy integration, J2EE technology and its component-based model simplify enterprise development and deployment.
Figure 4. J2EE application model

The J2EE application model divides enterprise applications into three fundamental parts: components , containers , and connectors . Components are the key focus of application developers, while system vendors implement containers and connectors to conceal complexity and promote portability. Containers intercede between clients and components, providing services transparently to both, including transaction support and resource pooling. Container mediation allows many component behaviors to be specified at deployment time, rather than in program code. Connectors sit beneath the J2EE platform, defining a portable service API to plug into existing enterprise vendor offerings. Connectors promote flexibility by enabling a variety of implementations of specific services.
Java technology within DB2 UDB Version 8
This section describes the enhancements to Java UDFs and stored procedures in DB2 Version 8.
You can create stored procedures and SQL language extensions, known as user-defined functions, in Java just as you would in other languages. Stored procedures must be registered within the database using the CREATE PROCEDURE statement. Java-based UDFs can be registered using the CREATE FUNCTION statement. You can then invoke the stored procedure from your application using any supported client API (such as JDBC, ODBC, SQLJ). The Java-based UDF can be invoked using any SQL statement. The stored procedure or UDF can be executed within its own address space (FENCED) or within the same address space as DB2 UDB (NOT FENCED).
In DB2 UDB Version 8, Java stored procedures and UDFs can now be registered as THREADSAFE or NOT THREADSAFE. The THREADSAFE option for Java procedures and functions will result in the use of a single JVM (Java Virtual Machine) on the DB2 UDB server. The default for Java procedures and functions in Version 8 is THREADSAFE, and therefore less memory is required for concurrent Java stored procedures. Performance can also be improved because there is no longer a need to load mutliple JVMs.
DB2 Java application development environment
The DB2 Development Center is a new feature in Version 8 designed to simplify the task of creating Java stored procedures and UDFs. WebSphere Studio is an integrated development environment (IDE) that enables you to build, test, and deploy Java applications to WebSphere Application Server and DB2 Universal Database. WebSphere Application Server provides a robust deployment environment for e-business applications. Its components let you build and deploy personalized, dynamic Web content quickly and easily. In this section, the Java application tools will be discussed, including:
DB2 Development Center (new for Version 8)
The DB2 Development Center is a replacement for the Stored Procedure Builder. It offers application developers facilities to build, debug, test and deploy Java stored procedures and user defined functions.
It can also be used to build, test, and deploy table functions that read MQSeries® (WebSphere MQ) messages, access OLE DB data sources and extract data from XML documents. The DB2 Development Center provides a standalone environment for developers. It can be used along side a complete Java IDE such as WebSphere Studio. For more information, see the DB2 Developer Domain article .
Figure 5. DB2 Development Center

The IBM WebSphere Studio family is a series of products built on a common IBM WebSphere Studio Workbench. The set of WebSphere Studio products is IBM's replacement technology for VisualAge® for Java. Each product in the WebSphere Studio family offers the same integrated development environment (IDE) and a common base of tools, for example for Java and Web development. The difference between these products lie in which plug-in tools are available in each configuration.
WebSphere Studio is a single, comprehensive development environment designed to meet all of your development needs -- from Web interfaces to server-side applications, from individual development to advanced team environments, from Java development to application integration. Available in a number of configurations, with extensions from IBM and other vendors, the WebSphere Studio family enables developers to use a single development environment designed to meet their specific development needs.
WebSphere Studio offers open standards, tool integration, and flexibility, including the ability to tie in existing applications. These are only some of the benefits that the WebSphere Studio product family delivers:
- Open standards: All the products in WebSphere Studio family are built on WebSphere Studio Workbench, which is IBM's implementation of the Eclipse platform. Eclipse is an open-source project that provides a common platform and set of APIs for creating plug-in development tools. For more information about the Eclipse project, see www.eclipse.org .
- Vertical and horizontal integration: Every WebSphere Studio product that is built on the workbench will offer tools that are already integrated, freeing you to focus on building applications rather than on integrating tools.
- Role-based development with consistent look and feel.
- Maximum programming performance.
- Support for J2EE business topologies.
WebSphere Studio Site Developer
WebSphere Studio Site Developer meets the needs of content authors, graphic artists, programmers, and Web developers. This integrated tool makes it easy to collaboratively create, assemble, publish, deploy, and maintain dynamic, interactive Web applications. You can quickly build and test business logic, and enhance presentation artifacts with built-in Web creation tools inside this IDE, before deploying on a production server.
WebSphere Studio Site Developer allows Web developers to create and deploy dynamic e-business applications quickly and efficiently. It also provides full Web services and XML development environments. WebSphere Studio Site Developer seamlessly interacts with many third-party tools.
IBM WebSphere Application Server provides packaging support for both Web and J2EE applications. It interacts with either IBM WebSphere Application Server or Apache Tomcat to publish Web applications directly to the application server. WebSphere Studio Site Developer is the most comprehensive Web authoring tool set available for creating compelling, advanced Web sites.
You can develop Web applications that employ the following technologies:
- JavaServer Pages (JSP) - A simple, fast, and consistent way to extend Web server functionality and create dynamic Web content. JSP pages enable rapid development of Web applications that are server and platform-independent.
- Servlets - Server applications that execute within a Web application. WebSphere Studio Site Developer supports the Java Servlet specification.
- Web services - Self-contained, modular applications that can be described, published, located, and invoked over the Internet or within intranets.
WebSphere Studio Application Developer
WebSphere Studio Application Developer includes all the features of WebSphere Studio Site Developer, plus additional plug-in tools for developers of complex, enterprise-wide J2EE applications. In addition to the HTML and JSP development tools mentioned above, WebSphere Studio Application Developer provides industry-leading support for building, testing, and deploying EJB components, plus integration components such as Java Connector Architecture (JCA)-based application adapters. It also optimized for the WebSphere software platform.
WebSphere Studio Application Developer provides profiling and logging tools so that you can detect application performance problems early in the development cycle. You can build and deploy custom application adapters to integrate with back-end systems, thereby increasing productivity by reusing existing resources. Furthermore, the built-in test environment for WebSphere Application Server and advanced tools for code generation help shorten the test cycle.
WebSphere Studio Application Developer is a complete Java, Web, Web services, Enterprise JavaBeans (EJB), and XML development environment. It provides wizards and other tools to enable rapid development of Web services applications. The Web services development tools provided in WebSphere Studio Application Developer are based on open, cross-platform standards: Universal Description Discovery and Integration (UDDI), Simple Object Access Protocol (SOAP) and Web Services Description Language (WSDL).
WebSphere Studio Application Developer facilitates the following processes to assist with building and deploying Web services-enabled applications:
- Create or transform. Create Web services from existing artifacts, such as Java beans and XML document.
- Build. Wrap existing artifacts as SOAP and HTTP accessible services and describe them in WSDL. The Web services wizards assist you in generating a SOAP proxy to Web services described in WSDL and in generating bean skeletons to classes.
- Deploy. Deploy Web services in the WebSphere Application Server or Tomcat test environments.
- Develop. Generate sample applications to assist you in creating a Web service client application.
- Test. Test Web services running locally or remotely.
- Publish. Publish Web services to the UDDI business registry, advertising your Web services so that other businesses can access them.
- Discover. Browse the UDDI business registry to locate existing Web services for integration.
WebSphere Studio Application Developer provides a comprehensive XML development environment that includes tools for building Document Type Definitions (DTDs), XML schemas, and XML files. It also supports integration of relational data and XML. You can use the Relational Database (RDB) to XML Mapping Editor to easily map relational data to XML formats. The editor can map columns in one or more relational tables to elements and attributes in an XML document. It can generate a Document Access Definition (DAD) file, which is used by DB2 XML Extender to either compose XML documents from existing DB2 data, or to decompose XML documents into DB2 data.
WebSphere Studio Application Developer contains a relational database environment to create and manipulate the data design for projects. It is an environment for exploring, importing, designing and querying databases. The SQL Query Builder provides a visual interface for creating and executing SQL statements.
WebSphere Studio Application Developer provides testing and publishing tools for testing enterprise applications. It provides a unit test environment for testing JSPs, servlets, and HTML files. It also provides the capability to configure other local or remote servers for integrating testing and debugging of Web and EJB applications. The server can be WebSphere Application Server, Apache Tomcat, or TCP/IP Monitoring Server.
DB2 UDB plug-ins for WebSphere Studio (New for Version 8)
The DB2 stored procedure and UDF builder component provides wizards and tools for creating and working with stored procedures and user-defined functions (UDFs) for use with DB2 Universal Database. When you create an application that accesses DB2 data, you can improve your application's performance by incorporating stored procedures and UDFs that are registered with the database server.
You can reduce network traffic and make better use of shared business logic. After you create a routine (stored procedure or UDF) with one of the wizards, you can modify it in the text editor. When you are satisfied, you can build it and register it on the DB2 server. After the routine is on the server, you can execute it and run the SQL statements that are included in the routine. When you run a routine, you can look in the Output view to see relevant information such as messages, parameters (input and output), and result sets that are returned. If you are not satisfied with the results, you can continue to modify and rebuild the routine until it returns the desired results.
Use this component to create the following types of routines:
- SQL and Java stored procedures
- SQL UDFs
- UDFs that read or receive messages from MQSeries message queues
You can:
- Create a new routine using a wizard.
- Modify existing routines using the text editor.
- Build (register) routines on the DB2 database server.
- Run (execute) routines on the DB2 database server.
- View result sets, messages, and parameters in the Output view.
- Drop routines from the database.
WebSphere Application Server is the foundation of the WebSphere software platform, WebSphere Application Server provides a rich, e-business application deployment environment with a complete set of application services including capabilities for transaction management, security, clustering, performance, availability, connectivity and scalability. It is a compliant Java 2 Platform, Enterprise Edition (J2EE) server.
DB2/WebSphere connection pooling Connection pooling support is provided with WebSphere Application Server. WebSphere connection pooling is the implementation of the JDBC 2.0 optional package API specification. Connection pooling spreads the connection overhead across several user requests by establishing a pool of connections which servlets can use. After the initial resources are spent to produce the connections in the pool, additional connect/disconnect overhead is insignificant because the existing connections are reused repeatedly.
DB2 maintains a pool of agent process/threads on the DB2 UDB server to satisfy client requests for database resources. WebSphere Application Server (WAS) connection pools are maintained independently from the DB2 server agent pool. Ensure that the allocated WAS connection pools are set in conjunction with the DB2 server agent configuration.
Statement caching WebSphere Application Server provides a prepared statement (PreparedStatement objects only) cache. This cache should be configured in conjunction with the DB2 package cache (PCKCACHESZ) for dynamic/static SQL statement processing. Depending on application data access patterns, the WAS prepared statement cache can improve application performance. Session persistence Persistent sessions are essential for using HTTP sessions for failover facility. When an application server receives a request associated with a session ID that it currently does not have in memory, it can obtain the required session state by accessing the external store (database or memory-to-memory). If persistent sessions are not enabled, an application server cannot access session information for HTTP requests that are sent to servers other than the one where the session was originally created.
The WebSphere Application Server stores session states in a DB2 database to provide fault tolerance for Web applications. If an application server goes offline, the state of its current sessions is still available in the DB2 database. This enables other application servers to continue processing. The DB2 tablespace page size configured within WAS. The default row size is 4K. WebSphere Applicatoin Server will exploit DB2's larger page size (32KB) for persisting session objects. This optimization results in improved application performance.
Enterprise JavaBeans As shown in
Figure 4, there are two types of application components known as Enterprise JavaBeans (EJBs): session beans and entity beans . Persistent data components are created using entity beans, while application logic components are created using session beans.
Session beans encapsulate temporary data associated with a particular client. Entity beans encapsulate permanent data that is stored in DB2. The persistence service ensures that the data associated with entity beans is properly synchronized with their corresponding data in the data source. To accomplish this task, the persistence service works with the transaction service to insert, update, extract, and remove data from the data source at the appropriate times.
There are two types of entity beans: those with container-managed persistence (CMP) and with bean-managed persistence (BMP) . WebSphere Studio provides the ideal environment for creating CMP EJBs. Once the EJBs have been mapped to corresponding DB2 tables and columns, WebSphere Studio generates the required JDBC code. This generated JDBC must be handled by the EJB developer if BMP EJBs are to be used.
Isolation level settings specify various degrees of runtime data
integrity provided by the corresponding database.
Table 1. Mapping isolation levels between J2EE and DB2
| J2EE isolation level | DB2 isolation level | Description |
|---|---|---|
| Serializable | Repeatable read | Prohibits dirty reads, nonrepeatable reads and phantom reads |
| Repeatable reads | Read stability | Prohibits dirty reads and nonrepeatable reads, but it allows phantom reads |
| Read committed | Cursor stability | Prohibits dirty reads, but allows nonrepeatable reads and phantom reads |
| Read uncommitted | Uncommitted read | Allows dirty reads, nonrepeatable reads and phantom reads |
There is a new DB2 UDB EJB-based sample provided with DB2 Version
8. The sample application includes a Web client which accesses the
DB2 sample database (db2sampl) using a JSP/servlet interface to a
Session/Entity EJB component. The sample application is contained
in the AccessEmployee.ear file, which is available in
the <DB2_root>\samples\java\Websphere\
directory on Windows platform and the
<DB_instance_home>/sqllib/samples/java/Websphere
directory on UNIX.
A full description of the EJB sample application and deployment
information is provided in the README file located in the
samples/Java directory.
Web services technology is essentially a new programming paradigm to aid in the development and deployment of loosely coupled applications within a company or across industries.
DB2 Web Services is an XML technology for simplify the creation of Web services that access relational databases. A DADX file is used to define the DB2 access operations. For more information about DB2 and Web services, see the DB2 Developer Domain Web services resource center at ibm.com/data/developer/webservices .
DB2 integrated Web services tutorial
IBM Video Central tutorial gives a sample solution for a company that provides business services to another company over the Web. This concept is known as a Business-to-Business application. The IBM Video Central tutorial demonstrates the integration of DB2 and WebSphere. Many technologies are used to design and build a fully functional application, including: IBM's WebSphere Application Server, VisualAge for Java, and the DB2 XML Extender. A set of centralized services for individual retail video stores is accessed using Simple Object Access Protocol (SOAP) (see http://www.w3.org/2000/xp/ ).
The IBM Video Central tutorial demonstrates the design, development, and implementation of simple data repository (insertion and modification) and query services. The query services use the existing DB2 XML Extender. The first version of the tutorial is provided using the Web, and it includes: Java Servlets, JSP (Java Server Pages), and the accompanying tutorial documentation.
This section describes the following features:
- DB2 XML-enabled databases
- WebSphere Studio - Relational database (RDB) to XML mapping editor
- MQSeries enablement
- Net Search Extender
Extensible Markup Language (XML) is the accepted standard technique of data exchange between applications. An XML document is a tagged document consisting of character data and markup tags. The markup tags are definable by the author of the document. A Document Type Definition (DTD) is used to declare the required data elements and attributes for an XML document. XML Schemas can be used to further qualify the data types of the elements and attributes of an XML document. The DB2 XML Extender provides a mechanism for programs to manipulate XML data using SQL extensions.
Previously, the XML Extender was a separately installed feature. In DB2 Version 8, it is part of the normal installation for DB2. To extend a DB2 UDB Version 8 database for XML usage simply enable the database using the dxxadm command. For example:
dxxadm enable_db sample
XML documents can be stored in DB2 within a single column or as a collection, using a set of columns. The DB2 XML Extender uses three data types: XMLVARCHAR, XMLCLOB, and XMLFILE. The Extender provides UDFs to store, extract and update XML documents stored within a single column. Searching can be performed on the entire XML document or based on structural components using the location path, which uses a subset of the abbreviated syntax defined by the XML Path Language (XPath). Side tables can be used to improve search performance for elements or attributes that are frequently queried.
To facilitate storing XML documents as a set of columns, the DB2 XML Extender provides an administration tool to aid the designer with XML-to-relational database mapping. The Document Access Definition (DAD) is used to maintain the structural and mapping data for the XML documents. The DAD is defined and stored as an XML document, making it simple to manipulate and understand. New stored procedures are available to compose or decompose the document.
New XML features for DB2 Version 8 include:
- XML schema validation
- XML stylesheet (transformation) support
- SQL/XML enhancements including: XMLAGG, XMLATTRIBUTES, XMLELEMENT, and XML2CLOB.
WebSphere Studio - Relational database (RDB) to XML mapping editor
Mapping from XML to relational data is simple using the WebSphere Studio RDB to XML mapping editor. The WebSphere Studio product is a replacement for the previous DB2 XML Extender Wizard used to create document access definition (DAD) files. You can map columns in one or more relational tables to elements and attributes in an XML document. You can generate a DAD script to either compose XML documents from existing DB2 data, or decompose XML documents into DB2 data. You can also create a test harness to test the generated DAD file.
The RDB to XML mapping editor is designed to work in conjunction with DB2 UDB Version 8 XML enabled databases. It simplifies development tasks in the following ways:
- Provides a visual interface to easily define mappings between relational data and XML elements and attributes.
- Automatically generates DAD files.
- Automatically generates a test harness.
A set of MQSeries functions are provided with DB2 Universal Database to allow DB2 UDB applications to interact with asynchronous messaging operations. Because these functions are available as SQL, this means that MQSeries support is available to applications written in any programming language supported by DB2 UDB.
DB2 UDB Version 8 provides a MQSeries Assist wizard within the DB2 Development Center. This wizard creates a table function that reads from an MQSeries queue using the MQSeries UDFs. The wizard can treat each MQSeries message as a delimited string or a fixed length column string. The created table function parses the string according to your specifications, and returns each MQSeries message as a row of the table function. The wizard also allows you to create a view on top of the table function and to preview an MQSeries message and the table function result.
For more information on DB2 and MQSeries integration, see the related DB2 Developer Domain article .
Using the DB2 XML Extender and MQSeries through SQL and XML
A series of SQL UDFs and stored procedures are supplied in DB2 enabling a DB2 client application to do the following from a single request:
- To read from MQSeries queues into DB2 XML columns
- To send and publish messages to MQseries queues from DB2 XML columns
- To send XML messages composed from relational data to MQSeries queues
- To decompose (shred) XML messages held in MQSeries queues into relational data
For more information, see the related DB2 Developer Domain article .
The DB2 Net Search Extender uses an indexing technique, known as n-gram index, to provide a new high-speed text search extender. There are many uses for this extender in the area of Web applications, as text fields are commonly queried by end users. Finding relevant documents based on text field indexes can improve Web user satisfaction. Any columns based on CHAR, VARCHAR, or LONG VARCHAR can be indexed using an n-gram index. When the index has been created and activated, searches can be performed using a new stored procedure. Active indexes are stored in shared memory to optimize search performance.
DB2 Version 8 Net Search Extender replaces all existing text extenders:
- DB2 Text Information Extender V7.2
- DB2 Text Extender V7.1
- DB2 Net Search Extender V7.2
The DB2 UDB Universal Developer's Edition Version 8 product delivers all the tools you need to rapidly build and deploy applications. The package includes a full-function integrated development environment, a scalable Web application server, and DB2 UDB features such as the XML Extender. DB2 Universal Database is a scalable, industrial-strength database that will be the data management foundation for your e-business.
Appendix A. IBM DB2 JDBC Universal Driver (Type 4)
This appendix describes the following information about the DB2 JDBC Type 4 driver:
- Requirements
- Determining JDBC driver information
- Trace facilities
- Behavior differences
- New driver properties
- Security
- Data sources
- New methods
- Current restrictions
A Java Runtime Environment at the 1.3.1 level is required.
IBM DB2 JDBC Universal Driver (type 4) requires prerequisite stored procedures and views on the target DB2 UDB server. DB2 UDB Version 8 on UNIX, Linux and Windows has the required stored procedures and views. For DB2 on OS/390, the stored procedures must be installed manually. Information for installing these stored procedures to DB2 for OS/390 Version 6 and Version 7 is available from the http://www.ibm.com/software/data/db2/os390/spb/sprocedure/index.html website.
Since the IBM DB2 JDBC Universal Driver (Type 4) uses TCP/IP for communications the DB2 UDB target server must be configured for TCP/IP.
Determining JDBC driver information
You can programmatically determine which JDBC driver has been loaded by your application using the following methods:
- java.sql.DatabaseMetaData.getDriverName()
- java.sql.DatabaseMetaData.getDriverMajorVersion()
- java.sql.DatabaseMetaData.getDriverMinorVersion()
- com.ibm.db2.jcc.DB2DatabaseMetaData.getJCCDriverBuildNumber()
DB2 JDBC Universal Driver (type 4) error handling relies on the installation of a prerequisite stored procedures on the target server. DB2 UDB Version 8 servers on UNIX, Linux, and Windows will have the required stored procedures created. DB2 for OS/390 Version 6 and Version 7 must have the stored procedures installed for the DB2 JDBC Universal Driver (type 4) driver to provide additional error messages.
Tracing can be enabled using DataSource properties (logWriter, traceLevel, traceFile). JDBC 1 connections must use the java.sql.DriverManager.setLogWriter() method.
The new DB2 JDBC Universal Driver (type 4) removes any dependency on DB2 Call Level Interface (CLI). Therefore, any previous db2cli.ini settings should be considered if you previously used DB2 JDBC drivers.
Connection (performance)
- boolean com.ibm.db2.jcc.DB2BaseDataSource.fullyMaterializeLobData - default is true
- boolean com.ibm.db2.jcc.DB2BaseDataSource.deferPrepares - default is true
int com.ibm.db2.jcc.DB2BaseDataSource.securityMechanism
- final static int com.ibm.db2.jcc.DB2BaseDataSource.USER_ONLY_SECURITY
- final static int com.ibm.db2.jcc.DB2BaseDataSource. CLEAR_TEXT_PASSWORD_SECURITY
- final static int com.ibm.db2.jcc.DB2BaseDataSource. ENCRYPTED_PASSWORD_SECURITY
- final static int com.ibm.db2.jcc.DB2BaseDataSource. ENCRYPTED_USER_AND_PASSWORD_SECURITY
- final static int com.ibm.db2.jcc.DB2BaseDataSource.KERBEROS_SECURITY
String com.ibm.db2.jcc.DB2BaseDataSource.kerberosServerPrincipal
transient org.ietf.jgss.GSSCredential com.ibm.db2.jcc.DB2BaseDataSource.gssCredential
void com.ibm.db2.jcc.DB2SimpleDataSource.setPassword (String password)
abstract class com.ibm.db2.jcc.DB2BaseDataSource
class com.ibm.db2.jcc.DB2SimpleDataSource
interface com.ibm.db2.jcc.DB2JccDataSource
- String getJccVersion()
DB2 Set Client Information (application identification)
- void com.ibm.db2.jcc.DB2Connection.setDB2ClientUser (String user)
- void com.ibm.db2.jcc.DB2Connection.setDB2ClientWorkstation (String name)
- void void com.ibm.db2.jcc.DB2Connection.setDB2ClientApplicationInformation (String info)
- void com.ibm.db2.jcc.DB2Connection.setDB2ClientAccountingInformation (String info)
- String com.ibm.db2.jcc.DB2Connection.getDB2ClientUser()
- String com.ibm.db2.jcc.DB2Connection.getDB2ClientWorkstation()
- String com.ibm.db2.jcc.DB2Connection.getDB2ClientApplicationInformation()
- String com.ibm.db2.jcc.DB2Connection.getDB2ClientAccountingInformation()
Current Packageset
- void com.ibm.db2.jcc.DB2Connection.setDB2CurrentPackageSet(String packageset)
- String com.ibm.db2.jcc.DB2Connection.getDB2CurrentPackageSet()
- String com.ibm.db2.jcc.DB2BaseDataSource.currentPackageSet
Trace
- transient java.io.PrintWriter com.ibm.db2.jcc.DB2BaseDataSource.logWriter
- void com.ibm.db2.jcc.DB2Connection.setJCCLogWriter (java.io.PrintWriter printWriter)
- void com.ibm.db2.jcc.DB2Connection.setJCCLogWriter (java.io.PrintWriter printWriter, int traceLevel)
- java.io.PrintWriter com.ibm.db2.jcc.DB2Connection.getJCCLogWriter()
- int com.ibm.db2.jcc.DB2BaseDataSource.traceLevel
- String com.ibm.db2.jcc.DB2BaseDataSource.traceFile
- final static int com.ibm.db2.jcc.DB2BaseDataSource.TRACE_NONE
- final static int com.ibm.db2.jcc.DB2BaseDataSource.TRACE_CONNECTION_CALLS
- final static int com.ibm.db2.jcc.DB2BaseDataSource.TRACE_STATEMENT_CALLS
- final static int com.ibm.db2.jcc.DB2BaseDataSource.TRACE_RESULT_SET_CALLS
- final static int com.ibm.db2.jcc.DB2BaseDataSource.TRACE_DRIVER_CONFIGURATION
- final static int com.ibm.db2.jcc.DB2BaseDataSource.TRACE_CONNECTS
- final static int com.ibm.db2.jcc.DB2BaseDataSource.TRACE_DRDA_FLOWS
- final static int com.ibm.db2.jcc.DB2BaseDataSource. TRACE_RESULT_SET_META_DATA
- final static int com.ibm.db2.jcc.DB2BaseDataSource. TRACE_PARAMETER_META_DATA
- final static int com.ibm.db2.jcc.DB2BaseDataSource.TRACE_DIAGNOSTICS
- final static int com.ibm.db2.jcc.DB2BaseDataSource.TRACE_SQLJ
- final static int com.ibm.db2.jcc.DB2BaseDataSource.TRACE_ALL
Diagnostics
- com.ibm.db2.jcc.DB2Diagnosable
- DB2Sqlca getSqlca ()
- java.lang.Throwable com.ibm.db2.jcc.DB2Diagnosable.getThrowable ()
- void printTrace (java.io.PrintWriter printWriter, String messageHeader)
- com.ibm.db2.jcc.DB2Sqlca
- String[] getSqlErrmcTokens ()
- String getSqlErrmc ()
- String getSqlErrp ()
- int[] getSqlErrd ()
- char[] getSqlWarn ()
- int getSqlCode ()
- String getSqlState ()
- String getMessage ()
- com.ibm.db2.jcc.DB2ExceptionFormatter
- static void printTrace (com.ibm.db2.jcc.DB2Sqlca sqlca, java.io.PrintWriter printWriter, String header)
- static void printTrace (SQLException sqlca, java.io.PrintWriter printWriter, String header)
- static void printTrace (java.lang.Throwable sqlca, java.io.PrintWriter printWriter, String header)
com.ibm.db2.jcc.DB2DatabaseMetaData
- int getJCCDriverBuildNumber()
com.ibm.db2.jcc.DB2Driver
- int getJCCBuildNumber()
- int getJCCBuildCertification()
- final static int jccTestBuild
- final static int jccBetaBuild
- final static int jccReleaseBuild
- String[] getJCCCompatibleJREVersions()
JDBC 2 Data Source and JDBC 1 Connection Properties
- int com.ibm.db2.jcc.DB2BaseDataSource.driverType
- String com.ibm.db2.jcc.DB2BaseDataSource.databaseName - specified in URL for JDBC 1 connectivity
- String com.ibm.db2.jcc.DB2BaseDataSource.description
- int com.ibm.db2.jcc.DB2BaseDataSource.portNumber - specified in URL for JDBC 1 connectivity
- String com.ibm.db2.jcc.DB2BaseDataSource.serverName - specified in URL for JDBC 1 connectivity
- String com.ibm.db2.jcc.DB2BaseDataSource.user
- int com.ibm.db2.jcc.DB2BaseDataSource.resultSetHoldability
- final static int com.ibm.db2.jcc.DB2BaseDataSource.HOLD_CURSORS_OVER_COMMIT
- final static int com.ibm.db2.jcc.DB2BaseDataSource.CLOSE_CURSORS_AT_COMMIT
- boolean com.ibm.db2.jcc.DB2BaseDataSource.fullyMaterializeLobData
- String com.ibm.db2.jcc.DB2BaseDataSource.currentPackageSet
- String com.ibm.db2.jcc.DB2BaseDataSource.planName
- int com.ibm.db2.jcc.DB2BaseDataSource.securityMechanism
- final static int com.ibm.db2.jcc.DB2BaseDataSource.USER_ONLY_SECURITY
- final static int com.ibm.db2.jcc.DB2BaseDataSource. CLEAR_TEXT_PASSWORD_SECURITY
- final static int com.ibm.db2.jcc.DB2BaseDataSource. ENCRYPTED_PASSWORD_SECURITY
- final static int com.ibm.db2.jcc.DB2BaseDataSource. ENCRYPTED_USER_AND_PASSWORD_SECURITY
- final static int com.ibm.db2.jcc.DB2BaseDataSource.KERBEROS_SECURITY
- String com.ibm.db2.jcc.DB2BaseDataSource.kerberosServerPrincipal
- transient org.ietf.jgss.GSSCredential com.ibm.db2.jcc.DB2BaseDataSource.gssCredential
- String com.ibm.db2.jcc.DB2BaseDataSource.traceFile
- int com.ibm.db2.jcc.DB2BaseDataSource.traceLevel
- final static int com.ibm.db2.jcc.DB2BaseDataSource.TRACE_NONE
- final static int com.ibm.db2.jcc.DB2BaseDataSource.TRACE_CONNECTION_CALLS
- final static int com.ibm.db2.jcc.DB2BaseDataSource.TRACE_STATEMENT_CALLS
- final static int com.ibm.db2.jcc.DB2BaseDataSource.TRACE_RESULT_SET_CALLS
- final static int com.ibm.db2.jcc.DB2BaseDataSource. TRACE_DRIVER_CONFIGURATION
- final static int com.ibm.db2.jcc.DB2BaseDataSource.TRACE_CONNECTS
- final static int com.ibm.db2.jcc.DB2BaseDataSource.TRACE_DRDA_FLOWS
- final static int com.ibm.db2.jcc.DB2BaseDataSource. TRACE_RESULT_SET_META_DATA
- final static int com.ibm.db2.jcc.DB2BaseDataSource. TRACE_PARAMETER_META_DATA
- final static int com.ibm.db2.jcc.DB2BaseDataSource.TRACE_DIAGNOSTICS
- final static int com.ibm.db2.jcc.DB2BaseDataSource.TRACE_SQLJ
- final static int com.ibm.db2.jcc.DB2BaseDataSource.TRACE_ALL
- transient java.io.PrintWriter com.ibm.db2.jcc.DB2BaseDataSource.logWriter
- boolean com.ibm.db2.jcc.DB2BaseDataSource.deferPrepares
- boolean com.ibm.db2.jcc.DB2BaseDataSource.readOnly
- java.util.Properties com.ibm.db2.jcc.DB2BaseDataSource.getProperties()
- User-defined structured types
- Connection pooling
- Arrays
- Distributed dransactions (JTA)
- Row sets
- Callable statement batches
See this article for more information on a sample application that used the JDBC 2.0 and type 4 driver: Writing a Web-based Table Editor GUI for DB2
For additional information, refer to the following Web sites:
DB2Universal Database resources:
WebSphere Developer Domain:
Comments (Undergoing maintenance)






