Before executing SQL statements, a JDBC or SQLJ application has to acquire a connection or connection context to a database. The database is identified by a database Uniform Resource Locator (URL) that is provided to the JDBC driver. The JDBC driver recognizes two types of URL:
It is recommended that you use a default URL in a CICS environment. The use of an explicit URL causes particular behaviours at the close of a connection, that could be inconvenient when multiple programs are used in the same application suite. Also, when a default URL is used, the connection behaves in the same way using the JDBC 1.2 driver, the JDBC 2.0 driver, or the DB2 Universal JDBC Driver. See Committing a unit of work for further information.
To acquire a connection to a database, applications need to provide the default or explicit URL of the database to the JDBC driver. The application can provide this URL using one of two methods, depending on the level of JDBC driver that is provided by your DB2 system. It can use the JDBC DriverManager interface, which is supported by the JDBC 1.2 driver, the JDBC 2.0 driver, and the DB2 Universal JDBC Driver; or it can use the DataSource interface, which is supported by the JDBC 2.0 driver and the DB2 Universal JDBC Driver. For descriptions of these two methods, see:
If you can use the JDBC 2.0 driver or the DB2 Universal JDBC Driver, the DataSource interface is the recommended method of acquiring a connection, because applications are then isolated from the platform-specific and JDBC driver-specific mechanisms for obtaining a connection to a database.
A Java™ application for CICS can have at most one JDBC connection or SQLJ connection context open at a time. Although JDBC allows an application to have multiple connections at the same time, CICS does not permit this. However, an application can close an existing connection and open a connection to a new DB2 location.
An application that has an open connection should close the connection before linking to another application that wants to use JDBC or SQLJ. For Java programs that are part of an application suite, you need to consider the implications of closing the connection, because if you are using an explicit URL, closing the connection can cause a syncpoint to be taken. If you are using a default URL, a syncpoint does not have to be taken when the connection is closed. See Committing a unit of work for more information about this.