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
>>-+-jdbc:db2:------+--//--server--+---------+--/--database----->
+-jdbc:db2j:net:-+ '-:--port-'
'-jdbc:ids:------'
>--+---------------------------+-------------------------------><
'-:--| connection-options |-'
connection-options
.---------------------.
V |
|----+-----------------+-+--------------------------------------|
'-property=value;-'
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 for Linux, UNIX, and Windows.
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: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 i server, all characters
in database must be uppercase characters.
- If the connection is to a DB2 for Linux, UNIX, and Windows 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);