background image
<< Obtaining Network Server runtime information | Client-specific DataSource properties >>

Accessing the Network Server

<< Obtaining Network Server runtime information | Client-specific DataSource properties >>
Derby Server and Administration Guide
20
Properties p = server.getCurrentProperties();
p.list(System.out);
System.out.println(p.getProperty("derby.drda.host"));
As shown in the previous example, you can look up the current properties and then work
with individual properties if needed by using various APIs on the Properties class. You
can also print out all the properties by using the Properties.list() method.
See
Managing the Derby Network Server remotely by using the servlet interface
for
information about obtaining system information using the servlet interface.
Accessing the Network Server by using the network client driver
When connecting to the Network Server, your application needs to load a driver and
connection URL that is specific to the Network Server. In addition, you must specify a
user name and password if you are using authentication.
The driver that you need to access the Network Server is:
org.apache.derby.jdbc.ClientDriver
The syntax of the URL that is required to access the Network Server is:
jdbc:derby://<server>[:<port>]/
<databaseName>[;<URL attribute>=<value> [;...]]
where the
<URL attribute>
is either a Derby embedded or network client attribute.
To access an in-memory database using the Network Server, the syntax is:
jdbc:derby://<server>[:<port>]/memory:
<databaseName>[;<URL attribute>=<value> [;...]]
For more information, see "Using in-memory databases" in the Derby Developer's Guide.
For both driver and DataSource access, the database name (including path), user,
password and other attribute values must consist of characters that can be converted
to UTF-8. The total byte length of the database name plus attributes when converted to
UTF-8 must not exceed 255 bytes; keep in mind that in UTF-8, a character may occupy
from 1 to 4 bytes. You may be able to work around this restriction for long paths or paths
that include multibyte characters by setting the
derby.system.home
system property
when starting the Network Server and accessing the database with a relative path that is
shorter and does not include multibyte characters.
The following table shows standard JDBC DataSource properties.
Table 4.
Standard JDBC DataSource properties
Property
Type
Description
URL
Attribute
Notes
databaseName
String
The name of
the database.
This property is
required.
None
This property is
also available using
EmbeddedDataSource.
dataSourceName
String
The data source
name.
None
This property is
also available using
EmbeddedDataSource.
description
String
A description of
the data source.
None
This property is
also available using
EmbeddedDataSource.