Java DB

Apache Derby

Derby Server and Administration Guide

Derby Getting Started
Derby Reference Manual
Derby Developer's Guide
Derby Performance Tuning
Derby Server and Admin Guide
Derby Tools and Utilities
Derby Server and Admin Guide
-Part one: Derby Server Guide
-Derby in a multi-user environment
-Using the Network Server with preexisting Derby applications
-The Network Server and JVMs
-Installing required jar files and adding them to the classpath
-Starting the Network Server
-Shutting down the Network Server
-Obtaining system information
-Accessing the Network Server by using the network client driver
-Accessing the Network Server by using a DataSource object
-XA and the Network Server
-Using the Derby tools with the Network Server
-Differences between running Derby in embedded mode and using the Network Server
-Setting port numbers
-Managing the Derby Network Server
-Managing the Derby Network Server remotely by using the servlet interface
-Derby Network Server advanced topics
-Derby Network Server sample programs
-Part two: Derby Administration Guide
-Checking database consistency
-Backing up and restoring databases
-Replicating databases
-Logging on a separate device
-Obtaining locking information
-Reclaiming unused space

 

Network client driver examples

The following examples specify the user and password URL attributes. To enable user authentication, the property derby.connection.requireAuthentication must be set to true, otherwise, Derby does not require a user name and password. For details on how to enable user authentication, please see "Working with user authentication" in the Derby Developer's Guide.

For a multi-user product, you would typically set it for the system in the derby.properties file for your server, since it is in a trusted environment. Below is a sample derby.properties file that conforms to these examples:
derby.connection.requireAuthentication=true
derby.authentication.provider=BUILTIN
derby.user.judy=no12see

Example 1

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

Example 2

The following example specifies both Derby and Network Client driver attributes:
jdbc:derby://localhost:1527/sample;create=true;user=judy;
password=no12see

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.

jdbc:derby://localhost:1527/c:/my-db-dir/my-db-name;user=judy;
password=no12see

Example 4

The following example shows how to use the network client driver to connect the network client to the Network Server:

String databaseURL = "jdbc:derby://localhost:1527/sample";
//
// Load Derby Network Client driver class
// If you are running on JDK 1.6 or higher, then you do not
// need to invoke Class.forName(). In that environment, the
// network client driver loads automatically.
//
Class.forName("org.apache.derby.jdbc.ClientDriver");
// Set user and password properties
Properties properties = new Properties();
properties.put("user", "judy");
properties.put("password", "no12see");
// Get a connection
Connection conn = DriverManager.getConnection(databaseURL, properties); 
 

javadb@jdbcurl.com