DB2 Version 9.7 for Linux, UNIX, and Windows

URL format for IBM Data Server Driver for JDBC and SQLJ type 2 connectivity

If you are using type 2 connectivity in your JDBC application, and you are making a connection using the DriverManager interface, you need to specify a URL in the DriverManager.getConnection call that indicates type 2 connectivity.

IBM Data Server Driver for JDBC and SQLJ type 2 connectivity URL syntax

Read syntax diagramSkip visual syntax diagram
>>---+-+-jdbc--:--db2--:--database----------+--+---------------------------+-+---><
     | +-jdbc--:--db2os390--:--database-----+  '-:--| connection-options |-' |     
     | +-jdbc--:--db2os390sqlj--:--database-+                                |     
     | '-jdbc--:--default--:--connection----'                                |     
     '-+-jdbc--:--db2os390--:-----+--+------------------------+--------------'     
       '-jdbc--:--db2os390sqlj--:-'  '-| connection-options |-'                    

connection-options

   .---------------------.   
   V                     |   
|----+-----------------+-+--------------------------------------|
     '-property=value;-'     

IBM Data Server Driver for JDBC and SQLJ type 2 connectivity URL options descriptions

The parts of the URL have the following meanings:

jdbc:db2: or jdbc:db2os390: or jdbc:db2os390sqlj: or jdbc:default:connection
The meanings of the initial portion of the URL are:
jdbc:db2: or jdbc:db2os390: or jdbc:db2os390sqlj:
Indicates that the connection is to a DB2® for z/OS® or DB2 for Linux, UNIX, and Windows server. jdbc:db2os390: and jdbc:db2os390sqlj: are for compatibility of programs that were written for older drivers, and apply to IBM® Data Server Driver for JDBC and SQLJ type 2 connectivity to DB2 for z/OS only.
jdbc:default:connection
Indicates that the URL is for a connection to the local subsystem through a DB2 thread that is controlled by CICS®, IMS™, or the Java™ stored procedure environment.
database
A name for the database server.
  • database is the database name that is defined during installation, if the value of the serverName connection property is null. If the value of serverName property is not null, database is a database alias.
property=value;
A property and its value for the JDBC connection. You can specify one or more property and value pairs. Each property and value pair, including the last one, must end with a semicolon (;). Do not include spaces or other white space characters anywhere within the list of property and value strings.
Some properties with an int data type have predefined constant field values. You must resolve constant field values to their integer values before you can use those values in the url parameter. For example, you cannot use com.ibm.db2.jcc.DB2BaseDataSource.TRACE_ALL in a url parameter. However, you can build a URL string that includes com.ibm.db2.jcc.DB2BaseDataSource.TRACE_ALL, and assign the URL string to a String variable. Then you can use the String variable in the url parameter:
    String url = 
     "jdbc:db2:STLEC1" +
     ":user=dbadm;password=dbadm;" +
     "traceLevel=" +
     (com.ibm.db2.jcc.DB2BaseDataSource.TRACE_ALL) + ";";
     Connection con = 
       java.sql.DriverManager.getConnection(url);