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 "Working with user authentication" in the Derby Developer's Guide.
For a multi-user product, you would typically specify authentication for the system in the derby.properties file for your server, since it is in a trusted environment. The following property setting specifies NATIVE authentication:
derby.authentication.provider=NATIVE:myCredentialsDB:LOCAL
The following example connects to the default server name localhost on the default port, 1527, and to the database sample.
jdbc:derby://localhost:1527/sample;user=judy;password=no12see
jdbc:derby://localhost:1527/sample;create=true;user=judy; password=no12see
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.
jdbc:derby://localhost:1527/c:/my-db-dir/my-db-name;user=judy; password=no12see
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.