background image
<< Embedded servers | Starting the Network Server >>

Using the Network Server

<< Embedded servers | Starting the Network Server >>
Derby Server and Administration Guide
14
props.setProperty("password","pwd");
/*
If you are running on JDK 6 or higher, you do not
need to invoke Class.forName(). In that environment, the
ClientDriver loads automatically.
*/
Class.forName("org.apache.derby.jdbc.ClientDriver");
Connection conn = DriverManager.getConnection(nsURL, props);
/*interact with Derby*/
Statement s = conn.createStatement();
ResultSet rs = s.executeQuery(
"SELECT * FROM HotelBookings");
About this guide and the Network Server documentation
This guide assumes that you are familiar with Derby features and tuning. Before reading
this guide, you should first learn about basic Derby functionality by reading the Derby
Developer's Guide
. Also, because multi-user environments typically have performance
and tuning issues, you should read Tuning Derby.
Using the Network Server with preexisting Derby applications
You must modify Java applications that currently run against Derby in embedded mode
so that they work with the Derby Network Server. The topics in this section discuss these
changes.
The Network Server and JVMs
The Derby Network Server is compatible with Java Platform, Standard Edition, v 1.4.2
(J2SE) and above.
Installing required jar files and adding them to the classpath
To use the Network Server and network client driver, add the following jar file to your
server classpath:
·
derbyrun.jar
Adding this file to your classpath has the effect of including all of the Derby classes in
your classpath. These classes are in the following jar files, which you can also add to
your classpath separately:
·
derbynet.jar
This jar file contains the Network Server code. It must be in your classpath to start
the Network Server.
·
derby.jar
This jar file contains the Derby database engine code. It must be in the classpath
in order for the Network Server to access Derby databases.
derby.jar
is
included in the Class-Path attribute of
derbynet.jar
's manifest file. If you have
derbynet.jar
in the classpath and
derby.jar
is in the same directory as
derbynet.jar
, it is not necessary to include
derby.jar
explicitly.
·
derbyclient.jar