background image
<< Create and run a JDBC program | Command to set the CLASSPATH environment variable >>
<< Create and run a JDBC program | Command to set the CLASSPATH environment variable >>

Command to start the Network Server

Getting Started with Derby
33
Operating
System
Command
UNIX (Korn
Shell)
cp WwdEmbedded.java WwdClient.java
Windows
copy WwdEmbedded.java WwdClient.java
d. Open the
WwdClient.java
file in a text editor and update the class name to
reflect the new file name:
Original declaration
public class WwdEmbedded
New declaration
public class WwdClient
e. Edit the DEFINE VARIABLES SECTION of the program so that the
driver
variable contains the name of the Derby client driver class and the
connectionURL
variable contains the hostname and port number of the
Network Server.
Original definitions
String driver = "org.apache.derby.jdbc.EmbeddedDriver";
String dbName="jdbcDemoDB";
String connectionURL = "jdbc:derby:" + dbName +
";create=true";
New definitions
String driver = "org.apache.derby.jdbc.ClientDriver";
...
String connectionURL = "jdbc:derby://localhost:1527/" +
dbName + ";create=true";
f. Compile the application.
javac WwdClient.java
A command prompt appears if the compilation is successful. The binary
file
WwdClient.class
is created. If an error message appears, modify
the line indicated so that it is identical to the example. (As noted above,
you can compare the contents of your
WwdClient.java
against the
WwdClientExample.java
program provided in the
workingwithderby
directory to verify that your editing was performed successfully.)
2. Set up the client/server environment using the following steps:
a. Open a command window (Server-Shell).
b. Change to the
DERBYTUTOR
directory.
c. Start the Network Server, as shown in the following table.
Table 19.
Command to start the Network Server
Operating
System
Command
UNIX (Korn
Shell)
java -jar $DERBY_HOME/lib/derbyrun.jar server
start
Wed Mar 02 17:45:31 EST 2011 : Security
manager installed using the Basic server
security policy.
Wed Mar 02 17:45:32 EST 2011 : Apache Derby
Network Server - 10.8.0.0 - (1076370) started
and ready to accept connections on port 1527
Windows
java -jar %DERBY_HOME%\lib\derbyrun.jar server
start