Accessing the Network Server by using the DB2 Universal Driver

You can use the DB2 Universal Driver instead of the Derby network client driver to connect to the Network Server. Your application needs to load the driver and connection URL that is specific to the Network Server. In addition, you specify a user name and password. If you have not set up authentication, you can use any value for the user name and password. The driver that you use to access the Network Server is:
com.ibm.db2.jcc.DB2Driver
You must have the following two jar files present in your classpath in order to use the DB2 Universal Driver:

The syntax of the URL that is required to access the Network Server is:

jdbc:derby:net://<server>[:<port>]/
<databaseName>[;<Derby URL attribute>=<value> [;...]]
[:<Universal Driver attribute>=<value>; [...;]]

After you specify the database name and attributes, you can include attributes for the DB2 JDBC Driver. You must include a semicolon after the last Universal Driver attribute.

server
The name of the machine where the server is running. It can be the name of the machine (for example, buffy) or the IP address, for example, 158.58.62.225.
Note: Unless the Network Server was started with the -h option or the derby.drda.host property set, this value must be localhost.
port
The port that the server is listening to. The default is 1527.
database name
The name of the database that you are connecting to. The database name can be a maximum of 18 characters. You must use quotation marks (") to include path information in the database name. Alternately, you can specify path information by setting the property derby.system.home in either the derby.properties file or in the Java environment when you start the Network Server. See the Derby Developer's Guide for more information about defining the system home.
derby URL attribute=value
Optional database connection URL attributes that are supported by Derby. See the Derby Developer's Guide for more information.
Universal Driver Attribute=value

Optional database connection URL attributes that are supported by the DB2 Universal JDBC Driver.

The DB2 JDBC Universal Driver requires that you set the Universal Driver user and password attributes to non-null values.

The following DB2 Universal JDBC Driver attributes are available to you when running the Network Server:

user

User name (required by the Universal JDBC Driver).

password

User password (required by the Universal JDBC Driver).

portNumber

The TCP/IP port number where the Network Server listens for connection requests to this data source. The default is 1527.

retrieveMessagesFromServerOnGetMessage

Displays error messages from the server.

readOnly

Creates a read-only connection. The default is false.

logWriter

A character output stream. All logging and tracing messages print to the logWriter property.

traceLevel

Specifies the granularity of logging messages to the logWriter property.

traceFile

Provides an explicit file location for the trace output.

securityMechanism

Indicates what type of security mechanism is used.

deferPrepares

Controls when prepared statements are physically prepared in the database server. The default value is true.

Universal Driver System information

The Derby Network Server is compatible with the DB2 JDBC Universal Driver release 2.4 and higher.

Related reference
Network client security
Network client tracing
Network client driver examples