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

If you are using type 4 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 4 connectivity.

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

Read syntax diagramSkip visual syntax diagram jdbc:db2:jdbc:db2j:net:jdbc:ids:jdbc:ibmdb: //server:port/database:connection-options
connection-options
Read syntax diagramSkip visual syntax diagram 1property= value;special-registersglobal-variablesquery-acceleration
special-registers
Read syntax diagramSkip visual syntax diagramspecialRegisters=,special-register-name= special-register-value;
global-variables
Read syntax diagramSkip visual syntax diagramglobalSessionVariables=,global-variable-name= global-variable-value;
query-acceleration
Read syntax diagramSkip visual syntax diagramqueryAcceleration=NONEENABLEENABLE WITH FAILBACKELIGIBLEALL;
Notes:
  • 1 property=value pairs, the special-registers string, and the global-variables string can be specified in any order.

IBM Data Server Driver for JDBC and SQLJ type 4 connectivity URL option descriptions

The parts of the URL have the following meanings:

jdbc:db2: or jdbc:db2j:net:
The meanings of the initial portion of the URL are:
jdbc:db2:
Indicates that the connection is to a Db2® for z/OS®, Db2 on Linux®, UNIX, and Windows systems.

jdbc:db2: can also be used for a connection to an IBM Informix® database, for application portability.

jdbc:db2j:net:
Indicates that the connection is to a remote IBM Cloudscape server.
jdbc:ibmdb:
Indicates that the connection is to any IBM Data Server that the IBM Data Server Driver for JDBC and SQLJ supports.
jdbc:ids:
Indicates that the connection is to an IBM Informix data source. jdbc:informix-sqli: also indicates that the connection is to an IBM Informix data source, but jdbc:ids: should be used.
server
The domain name or IP address of the data source.
port
The TCP/IP server port number that is assigned to the data source. This is an integer between 0 and 65535. The default is 446.
database
A name for the data source.
  • If the connection is to a Db2 for z/OS server, database is the Db2 location name that is defined during installation. All characters in the Db2 location name must be uppercase characters.

    The IBM Data Server Driver for JDBC and SQLJ does not convert lowercase characters in the database value to uppercase for IBM Data Server Driver for JDBC and SQLJ type 4 connectivity.

    You can determine the location name by executing the following SQL statement on the server:
    SELECT CURRENT SERVER FROM SYSIBM.SYSDUMMY1;
  • If the connection is to a Db2 for z/OS server or a Db2 for IBM i server, all characters in database must be uppercase characters.
  • If the connection is to a Db2 on Linux, UNIX, and Windows systems server, database is the database name that is defined during installation.
  • If the connection is to an IBM Informix server, database is the database name. The name is case-insensitive. The server converts the name to lowercase.
  • If the connection is to an IBM Cloudscape server, the database is the fully-qualified name of the file that contains the database. This name must be enclosed in double quotation marks ("). For example:
    "c:/databases/testdb"
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://sysmvs1.stl.ibm.com:5021/STLEC1" +
     ":user=dbadm;password=dbadm;" +
     "traceLevel=" +
     (com.ibm.db2.jcc.DB2BaseDataSource.TRACE_ALL) + ";";
     Connection con = 
       java.sql.DriverManager.getConnection(url);
specialRegisters=special-register-name=special-register-value,…special-register-name=special-register-value
A list of special register settings for the JDBC connection. You can specify one or more special register name and value pairs. Special register name and value pairs must be delimited by commas (,). The last pair must end with a semicolon (;). For example:
    String url = 
     "jdbc:db2://sysmvs1.stl.ibm.com:5021/STLEC1" +
     ":user=dbadm;password=dbadm;" +
     "specialRegisters=CURRENT_PATH=SYSIBM,CURRENT CLIENT_USERID=test" + ";";
    Connection con = 
       java.sql.DriverManager.getConnection(url);

For special registers that can be set through IBM Data Server Driver for JDBC and SQLJ Connection properties, if you set a special register value in a URL string using specialRegisters, and you also set that value in a java.util.Properties object using the following form of getConnection, the special register is set to the value from the URL string.

getConnection(String url, java.util.Properties info); 

You can specify only one value for each special register using the specialRegisters parameter. For special registers that take multiple values, such as CURRENT PATH, CURRENT PACKAGE PATH, CURRENT PACKAGESET, you can specify multiple values for a special register by using the DataSource interface and the DB2DataSource.setSpecialRegisters method.

Start of changeglobalSessionVariables=session-variable-name=session-variable-value,…session-variable-name=session-variable-valueEnd of change
Start of changeA list of session variable settings for the JDBC connection. You can specify one or more session variable name and value pairs.

Session variable settings apply only to Db2 for z/OS Version 11 or later data servers.

Session variable name and value pairs must be delimited by commas (,). The last pair must end with a semicolon (;). For example:

String url = 
     "jdbc:db2://sysmvs1.stl.ibm.com:5021/STLEC1" +
  ":user=dbadm;password=dbadm;" +
  "globalSessionVariables=SESSION.TEST=FAILED,SYSIBMADM.GET_ARCHIVE=Y" + ";";
Connection con = 
  java.sql.DriverManager.getConnection(url);
End of change
Start of changequeryAcceleration=value;End of change
Start of changeChanges the value of the CURRENT QUERY ACCELERATION special register.

Possible values are:

NONE
Specifies that no query acceleration is done.
ENABLE
Specifies that queries are accelerated only if Db2 determines that it is advantageous to do so. If there is an accelerator failure while a query is running, or the accelerator returns an error, Db2 returns a negative SQLCODE to the application.
ENABLE WITH FAILBACK
Specifies that queries are accelerated only if Db2 determines that it is advantageous to do so. If the accelerator returns an error during the PREPARE or first OPEN for the query, Db2 executes the query without the accelerator. If the accelerator returns an error during a FETCH or a subsequent OPEN, Db2 returns the error to the user, and does not execute the query.
ELIGIBLE
Specifies that queries are accelerated if they are eligible for acceleration. Db2 does not use cost information to determine whether to accelerate the queries. Queries that are not eligible for acceleration are executed by Db2. If there is an accelerator failure while a query is running, or the accelerator returns an error, Db2 returns a negative SQLCODE to the application.
ALL
Specifies that queries are accelerated if they are eligible for acceleration. Db2 does not use cost information to determine whether to accelerate the queries. Queries that are not eligible for acceleration are not executed by Db2, and an SQL error is returned. If there is an accelerator failure while a query is running, or the accelerator returns an error, Db2 returns a negative SQLCODE to the application.
End of change