Example 1The following example connects to the
default server name localhost on the default port, 1527, and
to the database sample. It specifies the URL attributes user, password, and retrieveMessagesFromServerOnGetMessage.
jdbc:derby:net://localhost:1527/sample:user=judy;password=no12see;
retrieveMessagesFromServerOnGetMessage=true;
Example 2The following example specifies the attributes
for both and the DB2 Driver
for JDBC: jdbc:derby:net://localhost:1527/sample;create=true:user=judy;
password=no12see;retrieveMessagesFromServerOnGetMessage=true;
Example 3This example connects to the default server
name localhost on the default port, 1527, and includes the path
in the database name portion of the URL. The database name must be delimited
by double quotation marks and you cannot specify attributes
on the URL.
jdbc:derby:net://localhost:1527/"c:/my-db-dir/my-db-name":user=judy;
password=no12see;retrieveMessagesFromServerOnGetMessage=true;
Example 4The following is a sample program fragment
that connects to the Network Server using the DB2 Driver for JDBC:
String databaseURL = "jdbc:derby:net://localhost:1527/sample";
// Load DB2 Driver for JDBC class
Class.forName("com.ibm.db2.jcc.DB2Driver");
// Set user and password properties
Properties properties = new Properties();
properties.put("user", "APP");
properties.put("password", "APP");
properties.put("retreiveMessagesFromServerOnGetMessage", "true");
// Get a connection
Connection conn = DriverManager.getConnection(databaseURL, properties);