Network client driver examples

The following examples specify the user and password URL attributes.

To enable user authentication, you must either use NATIVE authentication or explicitly set the property derby.connection.requireAuthentication to true. Otherwise, Derby does not require a user name and password. For details on how to enable user authentication, see "Configuring user authentication" in the Derby Security Guide.

For a multi-user product, you would typically specify authentication for the system in the file for your server, since it is in a trusted environment. The following property setting specifies NATIVE authentication:

Important: It is strongly recommended that production systems rely on NATIVE authentication, an external directory service such as LDAP, or a user-defined class for authentication. It is also strongly recommended that production systems protect network connections with SSL/TLS.

Example 1

The following example connects to the default server name localhost on the default port, 1527, and to the database sample.


Example 2

The following example specifies both Derby and Network Client driver attributes:


Example 3

This 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.


For a programming example that shows how to connect to the server using NATIVE authentication, see "NATIVE authentication and SQL authorization example" in the Derby Developer's Guide.

Related reference
Network client tracing