Acquiring a DriverManager connection to a database
Using the DriverManager class, the connection to the database is identified by a database Uniform Resource Locator (URL) that is provided to the JDBC driver.
About this task
A DriverManager connection is configured for an OSGi JVM server by specifying the DB2 JDBC jars and native DLLs in the JVM profile OSGI_BUNDLES and LIBPATH_SUFFIX JVM profile.
In a Liberty JVM server, the DriverManager configuration is provided by the CICS® JDBC Liberty feature.
- Default URL
- A default URL does not include the location name of a
DB2®
subsystem. A default URL for
DB2
for
z/OS®
can be specified in one of two formats:
jdbc:db2os390sqlj:
When a default URL is specified, the application is given a connection to the local DB2 to which CICS is connected. If your installation uses DB2 data sharing, you can access all the data in your sysplex from the local DB2.
or
jdbc:default:connection
- Explicit URL
- An explicit URL includes the location name of a
DB2
subsystem. The basic structure of an explicit
URL for
DB2
for
z/OS
is:
jdbc:db2os390:<location-name>
Typically, the location name is the name of the local DB2 to which CICS is connected. However, you can specify the name of a remote DB2 to access. In this case, CICS uses the local DB2 as a pass-through, and uses DB2 Distributed Data Facilities to access the remote DB2.
or
jdbc:db2os390sqlj:<location-name>
It is advisable to use a default URL when accessing DB2 with type 2 connectivity. The use of an explicit URL might cause specific actions when a connection closes that could be inconvenient when multiple programs are used in the same application suite. Also, when a default URL is used, the behavior of the connection is not affected by the JDBC driver version.
Connection connection =
DriverManager.getConnection("jdbc:default:connection");