db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kahat...@apache.org
Subject svn commit: r597835 [1/2] - in /db/derby/code/branches/10.3: java/demo/ java/demo/simple/ java/testing/org/apache/derbyTesting/functionTests/master/ tools/release/
Date Sat, 24 Nov 2007 11:11:19 GMT
Author: kahatlen
Date: Sat Nov 24 03:11:15 2007
New Revision: 597835

URL: http://svn.apache.org/viewvc?rev=597835&view=rev
Log:
DERBY-3118: Simple demo is out of date

Back-ported fix from trunk (revision 597661).
Contributed by John H. Embretsen.

Added:
    db/derby/code/branches/10.3/java/demo/README.txt
      - copied unchanged from r597661, db/derby/code/trunk/java/demo/README.txt
    db/derby/code/branches/10.3/java/demo/derbylogo128_bluebg.png
      - copied unchanged from r597661, db/derby/code/trunk/java/demo/derbylogo128_bluebg.png
Modified:
    db/derby/code/branches/10.3/java/demo/csfull.css
    db/derby/code/branches/10.3/java/demo/demo.html
    db/derby/code/branches/10.3/java/demo/navbar.html
    db/derby/code/branches/10.3/java/demo/readme.html
    db/derby/code/branches/10.3/java/demo/simple/SimpleApp.java
    db/derby/code/branches/10.3/java/demo/simple/example.html
    db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/master/SimpleApp.out
    db/derby/code/branches/10.3/tools/release/build.xml

Modified: db/derby/code/branches/10.3/java/demo/csfull.css
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.3/java/demo/csfull.css?rev=597835&r1=597834&r2=597835&view=diff
==============================================================================
--- db/derby/code/branches/10.3/java/demo/csfull.css (original)
+++ db/derby/code/branches/10.3/java/demo/csfull.css Sat Nov 24 03:11:15 2007
@@ -15,8 +15,8 @@
 * limitations under the License.
 */
 BODY {
-	font-size : 12pt;
-	font-family : "Times New Roman";
+	font-size : 10pt;
+	font-family : sans-serif;
 	background-color : White;
 }
 
@@ -25,15 +25,14 @@
 	background-color : transparent;
 }
 
-A:HOVER {
-	color : Fuchsia;
-	text-decoration : underline;
+A:VISITED {
+	color : #330099;
 	background-color : transparent;
 }
 
-	
-A:VISITED {
-	color : #330099;
+A:HOVER {
+	color : Teal;
+	text-decoration : underline;
 	background-color : transparent;
 }
 
@@ -49,25 +48,36 @@
 	background-color : transparent;
 }
 
-A.TOC:HOVER {
-	color : Fuchsia;
-	font-weight : bold;
-	background-color : transparent;
-}
-
-	
 A.TOC:VISITED {
 	color : #330099;
 	text-decoration : none;
 	background-color : transparent;
 }
 
+A.TOC:HOVER {
+	color : Fuchsia;
+	font-weight : bold;
+	background-color : transparent;
+}
+
 A.TOC:ACTIVE {
 	color : Purple;
 	text-decoration : none;
 	background-color : transparent;
 }
 
+a[id] {
+	/* All anchors with an id attribute get this style.
+	   Used to make sure internal links (links to a different section
+	   on the same page, i.e. named anchors) don't change appearance when
+	   hovering in CSS2-enabled browsers.
+	   Hence, links to other pages should not have the id attribute set,
+	   unless this particular solution is consciously abandoned.
+        */
+	color : #3300ff ! important;
+	text-decoration : none ! important;
+}
+
 .BadFormatting{
 	background-color : transparent;
 	font-size : 24pt;
@@ -82,6 +92,10 @@
 	font-size : 9pt;
 }
 
+.java {
+	background-color : transparent;
+	font-family: monospace;
+}
 
 .Output {
 	color : Gray;
@@ -124,6 +138,12 @@
 	font-weight : bold;
 }
 
+div.navMenu {
+	border-style: dashed;
+	border-width: thin;
+	border-color: #6699cc;
+}
+
 DL.Index {
 	font-size : 9pt;
 }
@@ -211,6 +231,7 @@
 }
 
 H3.BoxHead {
+	font-size : 90%;
 	margin-top : 1px;
 	margin-bottom : 6px;
 	color : Black;
@@ -303,7 +324,9 @@
 	margin-left : 2em;
 }
 
-
+IMG {
+	border : none;
+}
 
 LI{
 	margin-top : 12px;
@@ -465,10 +488,10 @@
 	font-size : 9pt;
 	margin-top:6px;
 	margin-bottom :6px;
-	padding-top : 2px;
+	padding-top : 2em;
 	padding-right : 2px;
 	padding-left : 2px;
-	padding-bottom : 2px;
+	padding-bottom : 2em;
 	background-color : transparent;
 }
 
@@ -646,15 +669,50 @@
 
 }
 
+PRE.Output {
+	background-color : transparent;
+	font-size : 10pt;
+	font-family : monospace;
+	color: gray;
+}
+
+TABLE.listing {
+	font-size : 100%;
+	background-color : #faf0e6;
+	border-style: solid;
+	border-color: silver;
+	border-width : 1px;
+}
+
 TABLE.Sample {
 	background-color : #FAF0E6;
 }
 
+TABLE.simple {
+	font-size : 100%;
+	border-style: solid;
+	border-width: 1px;
+	border-color: #6699cc;
+}
+
 TD.BoxTable {
 	background-color : Silver;
 	padding : 10px;
 }
 
+TD.listItem {
+	padding-top: 0.2em;
+	padding-bottom: 0.2em;
+	padding-left: 0.2em;
+	padding-right: 0.5em;
+}
+
+TD.heading {
+	font-weight : bold;
+	background-color : #6699cc;
+	color: #e7efff;
+}
+
 UL {
 	background-color : transparent;
 }
@@ -662,6 +720,11 @@
 	background-color : transparent;
 }
 
+UL.boxed {
+	background-color : transparent;
+	font-size : 9pt;
+	padding-bottom : 1em;
+}
 
 UL.CellBodyBulleted {
 	font-size : 10pt;
@@ -770,3 +833,18 @@
 	background-color : transparent;
 }
 
+var {
+	background-color : transparent;
+	color : Black;
+	font-weight : bold;
+	font-family : monospace;
+	font-size : 90%;
+}
+
+var.envVar {
+	font-style : normal;
+}
+
+var.property {
+	font-weight : normal;
+}

Modified: db/derby/code/branches/10.3/java/demo/demo.html
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.3/java/demo/demo.html?rev=597835&r1=597834&r2=597835&view=diff
==============================================================================
--- db/derby/code/branches/10.3/java/demo/demo.html (original)
+++ db/derby/code/branches/10.3/java/demo/demo.html Sat Nov 24 03:11:15 2007
@@ -23,14 +23,20 @@
 <BODY>
 
 <H1>Example Apache Derby Programs</H1>
-<p>This directory contains example programs. For a complete description, 
+<p>In this distribution of Apache Derby, the directory
+<em class="fileName">demo/programs/</em> contains example databases and programs
+written in Java. Some of the sample programs are used as references in some of
+the Derby user manuals,
 see <A href="../../docs/html/getstart/index.html">Getting Started with Apache Derby</A> and 
-the <A href="../../docs/html/adminguide/index.html">Apache Derby Server and Administration Guide</A> 
-.</p>
+the <A href="../../docs/html/adminguide/index.html">Apache Derby Server and Administration Guide</A>.
+Other programs are simply demonstrations of how to get started using Derby,
+or how to utilize certain features.</p>
 <UL>
 <LI><A href="simple/example.html">Simple</A>
         <p class="BodyRelative">A very simple JDBC application that boots the driver,
-                                creates a database, and loads some data.</p></LI>
+        creates a database, and loads some data. This application can run in both
+        embedded and client/server settings.</p>
+</LI>
 <li><a href="simplemobile/readme.html">Simple Mobile Demo</a>
     <p class="BodyRelative">A simple JDBC application for Java ME (J2ME) environments.
     This demo application uses Derby's EmbeddedSimpleDataSource to create a database and

Modified: db/derby/code/branches/10.3/java/demo/navbar.html
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.3/java/demo/navbar.html?rev=597835&r1=597834&r2=597835&view=diff
==============================================================================
--- db/derby/code/branches/10.3/java/demo/navbar.html (original)
+++ db/derby/code/branches/10.3/java/demo/navbar.html Sat Nov 24 03:11:15 2007
@@ -23,13 +23,16 @@
 </HEAD>
 <BODY class="SmallFile">
 
-<p class="NavBar"><a href="demo.html" target="mainPage">Demo home</a></li></p>
-<p class="NavBar1"><a href="simple/example.html" target="mainPage">Simple</a></p>
-<p class="NavBar1"><a href="simplemobile/readme.html" target="mainPage">Simple Mobile Demo</a></p>
-<p class="NavBar1"><a href="nserverdemo/readme.html" target="mainPage">Network Server Sample Programs</a></p>
-<p class="NavBar1"><a href="toursdb/toursdb_readme.html" target="mainPage">ToursDB sample database schema</a></p>
-<p class="NavBar1"><a href="workingwithderby/readme.html" target="mainPage">Getting Started With Derby Activities Programs</a></p>
-<p class="NavBar"><a href="http://db.apache.org/derby/manuals/index.html" target="_top">Documentation Home</a></p>
+<a href="../../index.html" target="_top"><img src="derbylogo128_bluebg.png" width="128" height="100" alt="Derby installation home page (Derby hat logo)"></a>
+<p class="NavBar"><a href="demo.html" target="mainPage">Demo home</a></p>
+<div class="navMenu">
+  <p class="NavBar1"><a href="simple/example.html" target="mainPage">Simple</a></p>
+  <p class="NavBar1"><a href="simplemobile/readme.html" target="mainPage">Simple Mobile Demo</a></p>
+  <p class="NavBar1"><a href="nserverdemo/readme.html" target="mainPage">Network Server Sample Programs</a></p>
+  <p class="NavBar1"><a href="toursdb/toursdb_readme.html" target="mainPage">ToursDB sample database schema</a></p>
+  <p class="NavBar1"><a href="workingwithderby/readme.html" target="mainPage">Getting Started With Derby Activities Programs</a></p>
+</div>
+<p class="NavBar"><a href="http://db.apache.org/derby/manuals/index.html" target="_top">Online Documentation</a></p>
 
 </BODY>
 </HTML>

Modified: db/derby/code/branches/10.3/java/demo/readme.html
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.3/java/demo/readme.html?rev=597835&r1=597834&r2=597835&view=diff
==============================================================================
--- db/derby/code/branches/10.3/java/demo/readme.html (original)
+++ db/derby/code/branches/10.3/java/demo/readme.html Sat Nov 24 03:11:15 2007
@@ -14,18 +14,15 @@
   See the License for the specific language governing permissions and
   limitations under the License.
 -->
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Frameset//EN">
 
 <html>
-<head><META http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+<head>
+    <META http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+    <title>Apache Derby demos</title>
 </head>
 <frameset cols="170, *">
-    <frame src="navbar.html" name="navbar" scrolling="Auto" noresize>	   
-    <frame src="demo.html" name="mainPage" scrolling="Auto">
+    <frame src="navbar.html" name="navbar" scrolling="Auto" noresize frameborder="0">
+    <frame src="demo.html" name="mainPage" scrolling="Auto" frameborder="0">
 </frameset>
-<body>
-
-
-
-</body>
 </html>

Modified: db/derby/code/branches/10.3/java/demo/simple/SimpleApp.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.3/java/demo/simple/SimpleApp.java?rev=597835&r1=597834&r2=597835&view=diff
==============================================================================
--- db/derby/code/branches/10.3/java/demo/simple/SimpleApp.java (original)
+++ db/derby/code/branches/10.3/java/demo/simple/SimpleApp.java Sat Nov 24 03:11:15 2007
@@ -21,226 +21,471 @@
 
 import java.sql.Connection;
 import java.sql.DriverManager;
+import java.sql.PreparedStatement;
 import java.sql.ResultSet;
 import java.sql.SQLException;
 import java.sql.Statement;
 
+import java.util.ArrayList;
 import java.util.Properties;
 
 
 /**
- * This sample program is a minimal JDBC application showing
- * JDBC access to Derby.
- *
+ * <p>
+ * This sample program is a minimal Java application showing JDBC access to a
+ * Derby database.</p>
+ * <p>
  * Instructions for how to run this program are
- * given in <A HREF=example.html>example.html</A>.
- *
+ * given in <A HREF=example.html>example.html</A>, by default located in the
+ * same directory as this source file ($DERBY_HOME/demo/programs/simple/).</p>
+ * <p>
  * Derby applications can run against Derby running in an embedded
- * or a client/server framework. When Derby runs in an embedded framework,
- * the Derby application and Derby run in the same JVM. The application
- * starts up the Derby engine. When Derby runs in a client/server framework,
- * the application runs in a different JVM from Derby. The application only needs
- * to start the client driver, and the connectivity framework provides network connections.
- * (The server must already be running.)
- *
- * <p>When you run this application, give one of the following arguments:
- *    * embedded (default, if none specified)
- *    * derbyclient (will use the Net client driver to access Network Server)
- *    * jccjdbcclient (if Derby is running embedded in the JCC Server framework)
- *
+ * or a client/server framework.</p>
+ * <p>
+ * When Derby runs in an embedded framework, the JDBC application and Derby
+ * run in the same Java Virtual Machine (JVM). The application
+ * starts up the Derby engine.</p>
+ * <p>
+ * When Derby runs in a client/server framework, the application runs in a
+ * different JVM from Derby. The application only needs to load the client
+ * driver, and the connectivity framework (in this case the Derby Network
+ * Server) provides network connections.</p>
  */
 public class SimpleApp
 {
     /* the default framework is embedded*/
-    public String framework = "embedded";
-    public String driver = "org.apache.derby.jdbc.EmbeddedDriver";
-    public String protocol = "jdbc:derby:";
-
+    private String framework = "embedded";
+    private String driver = "org.apache.derby.jdbc.EmbeddedDriver";
+    private String protocol = "jdbc:derby:";
+
+    /**
+     * <p>
+     * Starts the demo by creating a new instance of this class and running
+     * the <code>go()</code> method.</p>
+     * <p>
+     * When you run this application, you may give one of the following
+     * arguments:
+     *  <ul>
+          <li><code>embedded</code> - default, if none specified. Will use
+     *        Derby's embedded driver. This driver is included in the derby.jar
+     *        file.</li>
+     *    <li><code>derbyclient</code> - will use the Derby client driver to
+     *        access the Derby Network Server. This driver is included in the
+     *        derbyclient.jar file.</li>
+     *    <li><code>jccjdbcclient</code> - will use the DB2 Universal JDBC
+     *        network client driver, also known as JCC, to access the Network
+     *        Server. This driver is not part of the Derby distribution.</li>
+     *  </ul>
+     * <p>
+     * When you are using a client/server framework, the network server must
+     * already be running when trying to obtain client connections to Derby.
+     * This demo program will will try to connect to a network server on this
+     * host (the localhost), see the <code>protocol</code> instance variable.
+     * </p>
+     * <p>
+     * When running this demo, you must include the correct driver in the
+     * classpath of the JVM. See <a href="example.html">example.html</a> for
+     * details.
+     * </p>
+     * @param args This program accepts one optional argument specifying which
+     *        connection framework (JDBC driver) to use (see above). The default
+     *        is to use the embedded JDBC driver.
+     */
     public static void main(String[] args)
     {
         new SimpleApp().go(args);
+        System.out.println("SimpleApp finished");
     }
 
+    /**
+     * <p>
+     * Starts the actual demo activities. This includes loading the correct
+     * JDBC driver, creating a database by making a connection to Derby,
+     * creating a table in the database, and inserting, updating and retreiving
+     * some data. Some of the retreived data is then verified (compared) against
+     * the expected results. Finally, the table is deleted and, if the embedded
+     * framework is used, the database is shut down.</p>
+     * <p>
+     * Generally, when using a client/server framework, other clients may be
+     * (or want to be) connected to the database, so you should be careful about
+     * doing shutdown unless you know that noone else needs to access the
+     * database until it is rebooted. That is why this demo will not shut down
+     * the database unless it is running Derby embedded.</p>
+     *
+     * @param args - Optional argument specifying which framework or JDBC driver
+     *        to use to connect to Derby. Default is the embedded framework,
+     *        see the <code>main()</code> method for details.
+     * @see #main(String[])
+     */
     void go(String[] args)
     {
         /* parse the arguments to determine which framework is desired*/
         parseArguments(args);
 
-        System.out.println("SimpleApp starting in " + framework + " mode.");
+        System.out.println("SimpleApp starting in " + framework + " mode");
+
+        /* load the desired JDBC driver */
+        loadDriver();
 
+        /* We will be using Statement and PreparedStatement objects for
+         * executing SQL. These objects, as well as Connections and ResultSets,
+         * are resources that should be released explicitly after use, hence
+         * the try-catch-finally pattern used below.
+         * We are storing the Statement and Prepared statement object references
+         * in an array list for convenience.
+         */
+        Connection conn = null;
+	/* This ArrayList usage may cause a warning when compiling this class
+	 * with a compiler for J2SE 5.0 or newer. We are not using generics
+	 * because we want the source to support J2SE 1.4.2 environments. */
+        ArrayList statements = new ArrayList(); // list of Statements, PreparedStatements
+        PreparedStatement psInsert = null;
+        PreparedStatement psUpdate = null;
+        Statement s = null;
+        ResultSet rs = null;
         try
         {
-            /*
-               The driver is installed by loading its class.
-               In an embedded environment, this will start up Derby, since it is not already running.
-             */
-            Class.forName(driver).newInstance();
-            System.out.println("Loaded the appropriate driver.");
-
-            Connection conn = null;
-            Properties props = new Properties();
+            Properties props = new Properties(); // connection properties
+            // providing a user name and password is optional in the embedded
+            // and derbyclient frameworks
             props.put("user", "user1");
             props.put("password", "user1");
 
-            /*
-               The connection specifies create=true to cause
-               the database to be created. To remove the database,
-               remove the directory derbyDB and its contents.
-               The directory derbyDB will be created under
-               the directory that the system property
-               derby.system.home points to, or the current
-               directory if derby.system.home is not set.
+            /* By default, the schema APP will be used when no username is
+             * provided.
+             * Otherwise, the schema name is the same as the user name (in this
+             * case "user1" or USER1.)
+             *
+             * Note that user authentication is off by default, meaning that any
+             * user can connect to your database using any password. To enable
+             * authentication, see the Derby Developer's Guide.
              */
-            conn = DriverManager.getConnection(protocol +
-                    "derbyDB;create=true", props);
-
-            System.out.println("Connected to and created database derbyDB");
 
-            conn.setAutoCommit(false);
+            String dbName = "derbyDB"; // the name of the database
 
             /*
-               Creating a statement lets us issue commands against
-               the connection.
+             * This connection specifies create=true in the connection URL to
+             * cause the database to be created when connecting for the first
+             * time. To remove the database, remove the directory derbyDB (the
+             * same as the database name) and its contents.
+             *
+             * The directory derbyDB will be created under the directory that
+             * the system property derby.system.home points to, or the current
+             * directory (user.dir) if derby.system.home is not set.
              */
-            Statement s = conn.createStatement();
+            conn = DriverManager.getConnection(protocol + dbName
+                    + ";create=true", props);
 
-            /*
-               We create a table, add a few rows, and update one.
+            System.out.println("Connected to and created database " + dbName);
+
+            // We want to control transactions manually. Autocommit is on by
+            // default in JDBC.
+            conn.setAutoCommit(false);
+
+            /* Creating a statement object that we can use for running various
+             * SQL statements commands against the database.*/
+            s = conn.createStatement();
+            statements.add(s);
+
+            // We create a table...
+            s.execute("create table location(num int, addr varchar(40))");
+            System.out.println("Created table location");
+
+            // and add a few rows...
+
+            /* It is recommended to use PreparedStatements when you are
+             * repeating execution of an SQL statement. PreparedStatements also
+             * allows you to parameterize variables. By using PreparedStatements
+             * you may increase performance (because the Derby engine does not
+             * have to recompile the SQL statement each time it is executed) and
+             * improve security (because of Java type checking).
              */
-            s.execute("create table derbyDB(num int, addr varchar(40))");
-            System.out.println("Created table derbyDB");
-            s.execute("insert into derbyDB values (1956,'Webster St.')");
+            // parameter 1 is num (int), parameter 2 is addr (varchar)
+            psInsert = conn.prepareStatement(
+                        "insert into location values (?, ?)");
+            statements.add(psInsert);
+
+            psInsert.setInt(1, 1956);
+            psInsert.setString(2, "Webster St.");
+            psInsert.executeUpdate();
             System.out.println("Inserted 1956 Webster");
-            s.execute("insert into derbyDB values (1910,'Union St.')");
+
+            psInsert.setInt(1, 1910);
+            psInsert.setString(2, "Union St.");
+            psInsert.executeUpdate();
             System.out.println("Inserted 1910 Union");
-            s.execute(
-                "update derbyDB set num=180, addr='Grand Ave.' where num=1956");
+
+            // Let's update some rows as well...
+
+            // parameter 1 and 3 are num (int), parameter 2 is addr (varchar)
+            psUpdate = conn.prepareStatement(
+                        "update location set num=?, addr=? where num=?");
+            statements.add(psUpdate);
+
+            psUpdate.setInt(1, 180);
+            psUpdate.setString(2, "Grand Ave.");
+            psUpdate.setInt(3, 1956);
+            psUpdate.executeUpdate();
             System.out.println("Updated 1956 Webster to 180 Grand");
 
-            s.execute(
-                "update derbyDB set num=300, addr='Lakeshore Ave.' where num=180");
+            psUpdate.setInt(1, 300);
+            psUpdate.setString(2, "Lakeshore Ave.");
+            psUpdate.setInt(3, 180);
+            psUpdate.executeUpdate();
             System.out.println("Updated 180 Grand to 300 Lakeshore");
 
+
             /*
                We select the rows and verify the results.
              */
-            ResultSet rs = s.executeQuery(
-                    "SELECT num, addr FROM derbyDB ORDER BY num");
+            rs = s.executeQuery(
+                    "SELECT num, addr FROM location ORDER BY num");
 
+            /* we expect the first returned column to be an integer (num),
+             * and second to be a String (addr). Rows are sorted by street
+             * number (num).
+             *
+             * Normally, it is best to use a pattern of
+             *  while(rs.next()) {
+             *    // do something with the result set
+             *  }
+             * to process all returned rows, but we are only expecting two rows
+             * this time, and want the verification code to be easy to
+             * comprehend, so we use a different pattern.
+             */
+
+            int number; // street number retreived from the database
+            boolean failure = false;
             if (!rs.next())
             {
-                throw new Exception("Wrong number of rows");
+                failure = true;
+                reportFailure("No rows in ResultSet");
             }
 
-            if (rs.getInt(1) != 300)
+            if ((number = rs.getInt(1)) != 300)
             {
-                throw new Exception("Wrong row returned");
+                failure = true;
+                reportFailure(
+                        "Wrong row returned, expected num=300, got " + number);
             }
 
             if (!rs.next())
             {
-                throw new Exception("Wrong number of rows");
+                failure = true;
+                reportFailure("Too few rows");
             }
 
-            if (rs.getInt(1) != 1910)
+            if ((number = rs.getInt(1)) != 1910)
             {
-                throw new Exception("Wrong row returned");
+                failure = true;
+                reportFailure(
+                        "Wrong row returned, expected num=1910, got " + number);
             }
 
             if (rs.next())
             {
-                throw new Exception("Wrong number of rows");
+                failure = true;
+                reportFailure("Too many rows");
             }
 
-            System.out.println("Verified the rows");
+            if (!failure) {
+                System.out.println("Verified the rows");
+            }
 
-            s.execute("drop table derbyDB");
-            System.out.println("Dropped table derbyDB");
+            // delete the table
+            s.execute("drop table location");
+            System.out.println("Dropped table location");
 
             /*
-               We release the result and statement resources.
-             */
-            rs.close();
-            s.close();
-            System.out.println("Closed result set and statement");
-
-            /*
-               We end the transaction and the connection.
+               We commit the transaction. Any changes will be persisted to
+               the database now.
              */
             conn.commit();
-            conn.close();
-            System.out.println("Committed transaction and closed connection");
+            System.out.println("Committed the transaction");
 
             /*
-               In embedded mode, an application should shut down Derby.
-               If the application fails to shut down Derby explicitly,
-               the Derby does not perform a checkpoint when the JVM shuts down, which means
-               that the next connection will be slower.
-               Explicitly shutting down Derby with the URL is preferred.
-               This style of shutdown will always throw an "exception".
+             * In embedded mode, an application should shut down the database.
+             * If the application fails to shut down the database,
+             * Derby will not perform a checkpoint when the JVM shuts down.
+             * This means that it will take longer to boot (connect to) the
+             * database the next time, because Derby needs to perform a recovery
+             * operation.
+             *
+             * It is also possible to shut down the Derby system/engine, which
+             * automatically shuts down all booted databases.
+             *
+             * Explicitly shutting down the database or the Derby engine with
+             * the connection URL is preferred. This style of shutdown will
+             * always throw an SQLException.
+             *
+             * Not shutting down when in a client environment, see method
+             * Javadoc.
              */
-            boolean gotSQLExc = false;
 
             if (framework.equals("embedded"))
             {
                 try
                 {
+                    // the shutdown=true attribute shuts down Derby
                     DriverManager.getConnection("jdbc:derby:;shutdown=true");
-                }
-                catch (SQLException se)
-                {
-                    gotSQLExc = true;
-                }
 
-                if (!gotSQLExc)
-                {
-                    System.out.println("Database did not shut down normally");
+                    // To shut down a specific database only, but keeep the
+                    // engine running (for example for connecting to other
+                    // databases), specify a database in the connection URL:
+                    //DriverManager.getConnection("jdbc:derby:" + dbName + ";shutdown=true");
                 }
-                else
+                catch (SQLException se)
                 {
-                    System.out.println("Database shut down normally");
+                    if (( (se.getErrorCode() == 50000)
+                            && ("XJ015".equals(se.getSQLState()) ))) {
+                        // we got the expected exception
+                        System.out.println("Derby shut down normally");
+                        // Note that for single database shutdown, the expected
+                        // SQL state is "08006", and the error code is 45000.
+                    } else {
+                        // if the error code or SQLState is different, we have
+                        // an unexpected exception (shutdown failed)
+                        System.err.println("Derby did not shut down normally");
+                        printSQLException(se);
+                    }
                 }
             }
         }
-        catch (Throwable e)
+        catch (SQLException sqle)
         {
-            System.out.println("exception thrown:");
+            printSQLException(sqle);
+        } finally {
+            // release all open resources to avoid unnecessary memory usage
+
+            // ResultSet
+            try {
+                if (rs != null) {
+                    rs.close();
+                    rs = null;
+                }
+            } catch (SQLException sqle) {
+                printSQLException(sqle);
+            }
 
-            if (e instanceof SQLException)
-            {
-                printSQLError((SQLException) e);
+            // Statements and PreparedStatements
+            int i = 0;
+            while (!statements.isEmpty()) {
+                // PreparedStatement extend Statement
+                Statement st = (Statement)statements.remove(i);
+                try {
+                    if (st != null) {
+                        st.close();
+                        st = null;
+                    }
+                } catch (SQLException sqle) {
+                    printSQLException(sqle);
+                }
             }
-            else
-            {
-                e.printStackTrace();
+
+            //Connection
+            try {
+                if (conn != null) {
+                    conn.close();
+                    conn = null;
+                }
+            } catch (SQLException sqle) {
+                printSQLException(sqle);
             }
         }
+    }
 
-        System.out.println("SimpleApp finished");
+    /**
+     * Loads the appropriate JDBC driver for this environment/framework. For
+     * example, if we are in an embedded environment, we load Derby's
+     * embedded Driver, <code>org.apache.derby.jdbc.EmbeddedDriver</code>.
+     */
+    private void loadDriver() {
+        /*
+         *  The JDBC driver is loaded by loading its class.
+         *  If you are using JDBC 4.0 (Java SE 6) or newer, JDBC drivers may
+         *  be automatically loaded, making this code optional.
+         *
+         *  In an embedded environment, this will also start up the Derby
+         *  engine (though not any databases), since it is not already
+         *  running. In a client environment, the Derby engine is being run
+         *  by the network server framework.
+         *
+         *  In an embedded environment, any static Derby system properties
+         *  must be set before loading the driver to take effect.
+         */
+        try {
+            Class.forName(driver).newInstance();
+            System.out.println("Loaded the appropriate driver");
+        } catch (ClassNotFoundException cnfe) {
+            System.err.println("\nUnable to load the JDBC driver " + driver);
+            System.err.println("Please check your CLASSPATH.");
+            cnfe.printStackTrace(System.err);
+        } catch (InstantiationException ie) {
+            System.err.println(
+                        "\nUnable to instantiate the JDBC driver " + driver);
+            ie.printStackTrace(System.err);
+        } catch (IllegalAccessException iae) {
+            System.err.println(
+                        "\nNot allowed to access the JDBC driver " + driver);
+            iae.printStackTrace(System.err);
+        }
+    }
+
+    /**
+     * Reports a data verification failure to System.err with the given message.
+     *
+     * @param message A message describing what failed.
+     */
+    private void reportFailure(String message) {
+        System.err.println("\nData verification failed:");
+        System.err.println('\t' + message);
     }
 
-    static void printSQLError(SQLException e)
+    /**
+     * Prints details of an SQLException chain to <code>System.err</code>.
+     * Details included are SQL State, Error code, Exception message.
+     *
+     * @param e the SQLException from which to print details.
+     */
+    public static void printSQLException(SQLException e)
     {
+        // Unwraps the entire exception chain to unveil the real cause of the
+        // Exception.
         while (e != null)
         {
-            System.out.println(e.toString());
+            System.err.println("\n----- SQLException -----");
+            System.err.println("  SQL State:  " + e.getSQLState());
+            System.err.println("  Error Code: " + e.getErrorCode());
+            System.err.println("  Message:    " + e.getMessage());
+            // for stack traces, refer to derby.log or uncomment this:
+            //e.printStackTrace(System.err);
             e = e.getNextException();
         }
     }
 
+    /**
+     * Parses the arguments given and sets the values of this class' instance
+     * variables accordingly - that is which framework to use, the name of the
+     * JDBC driver class, and which connection protocol protocol to use. The
+     * protocol should be used as part of the JDBC URL when connecting to Derby.
+     * <p>
+     * If the argument is "embedded" or invalid, this method will not change
+     * anything, meaning that the default values will be used.</p>
+     * <p>
+     * @param args JDBC connection framework, either "embedded", "derbyclient"
+     *        or "jccjdbcclient". Only the first argument will be considered,
+     *        the rest will be ignored.
+     */
     private void parseArguments(String[] args)
     {
-        int length = args.length;
-
-        for (int index = 0; index < length; index++)
-        {
-            if (args[index].equalsIgnoreCase("jccjdbcclient"))
+        if (args.length > 0) {
+            if (args[0].equalsIgnoreCase("jccjdbcclient"))
             {
                 framework = "jccjdbc";
                 driver = "com.ibm.db2.jcc.DB2Driver";
                 protocol = "jdbc:derby:net://localhost:1527/";
             }
-            if (args[index].equalsIgnoreCase("derbyclient"))
+            else if (args[0].equalsIgnoreCase("derbyclient"))
             {
                 framework = "derbyclient";
                 driver = "org.apache.derby.jdbc.ClientDriver";

Modified: db/derby/code/branches/10.3/java/demo/simple/example.html
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.3/java/demo/simple/example.html?rev=597835&r1=597834&r2=597835&view=diff
==============================================================================
--- db/derby/code/branches/10.3/java/demo/simple/example.html (original)
+++ db/derby/code/branches/10.3/java/demo/simple/example.html Sat Nov 24 03:11:15 2007
@@ -18,533 +18,599 @@
 <html>
 <head>
 <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
-<meta name="LASTUPDATED" content="2007-11-08 09:18:20 UTC">
+<meta name="LASTUPDATED" content="2007-11-20 13:04:00 UTC">
 <link rel="StyleSheet" href="../csfull.css" type="text/css" media="screen">
 <title>Simple JDBC Application</title>
-
-<script language="JavaScript">
-<!--
-var isNav, isIE, inFrame;
-
-if (parseInt(navigator.appVersion) >= 4) {
-    if (navigator.appName == "Netscape") {
-	isNav = true
-	} else {
-	isIE = true
-	}
-}
-if (parent.frames.length > 0)
-    inFrame = true;
-else
-	inFrame = false;
-
-
-
-
-//-->
-</script>
-
-
-
 </head>
 <body>
-
-
-
-
-
 <h1 class="Title">
-  <a name="811209"> </a>Simple JDBC Application
+  Simple JDBC Application
 </h1>
  
-
-<ul class="ChapterTOC">  <li class="ChapterTOC"><a name="820053"> </a>  <a href="#820067">Overview</a>
-  <li class="ChapterTOC">  <a href="#816689">What's Included?</a>
-  <li class="ChapterTOC">  <a href="#816722">How to run this sample application in an embedded environment</a>
-<li class="ChapterTOC">  <a href="#816723">How to run this sample application in a server environment</a>
+<!-- ##########  TABLE OF CONTENTS  ########## -->
+<ul class="ChapterTOC">
+  <li class="ChapterTOC"><a href="#overview">Overview</a>
+  <li class="ChapterTOC"><a href="#included">What's Included?</a>
+  <li class="ChapterTOC"><a href="#runembedded">How to run this sample application in an embedded environment</a>
+  <li class="ChapterTOC"><a href="#runclientserver">How to run this sample application in a client/server environment</a>
+  <ul class="SubList">
+    <li class="ChapterToc"><a href="#server">Starting the Network Server</a>
+    <li class="ChapterToc"><a href="#derbyclient">Using the Derby client driver</a>
+    <li class="ChapterToc"><a href="#jcc">Using the IBM DB2 Universal JDBC driver</a>
+  </ul>
 </ul>
-<h2 class="Heading2"><a name="820067"> </a>Overview
+
+<!-- ##########  OVERVIEW  ########## -->
+<h2 class="Heading2"><a id="overview" name="overview">Overview</a>
 </h2>
- <p class="Body">
-  <a name="820012"> </a>This example program is a very minimal JDBC application. JDBC is the primary API for interacting with Apache Derby. This program:
-</p><ul class="Normal">  
-  <li class="Normal">runs in either embedded mode (the default) or as a client in a server environment, depending on the arguments passed to the program.
-  <li class="Normal"><a name="817266"> </a>starts up the Derby engine, if running in embedded mode
-  <li class="Normal"><a name="817266"> </a>connects to the Derby Network Server, if running in client mode
-  <li class="Normal"><a name="817275"> </a>creates and connects to a database
-  <li class="Normal"><a name="817276"> </a>creates a table
-  <li class="Normal"><a name="817277"> </a>inserts data
-  <li class="Normal"><a name="817278"> </a>updates data
-  <li class="Normal"><a name="817279"> </a>selects data
-  <li class="Normal"><a name="817280"> </a>drops a table
-  <li class="Normal"><a name="817281"> </a>disconnects
-  <li class="Normal"><a name="817282"> </a>shuts down Derby, if running in embedded mode
+<p>
+  This example program is a minimal JDBC application written in Java. JDBC is
+  the primary API for interacting with Apache Derby using Java. This program:
+</p>
+<ul class="Normal">
+  <li class="Normal">runs in either embedded mode (the default) or as a client in a client/server environment, depending on the arguments passed to the program
+  <li class="Normal">starts up the Derby engine, if running in embedded mode
+  <li class="Normal">connects to the Derby Network Server, if running in client mode
+  <li class="Normal">creates and connects to a database
+  <li class="Normal">creates a table
+  <li class="Normal">inserts data
+  <li class="Normal">updates data
+  <li class="Normal">selects data
+  <li class="Normal">drops a table
+  <li class="Normal">disconnects
+  <li class="Normal">shuts down the database, if running in embedded mode
 </ul>
-<p class="Body">
-  <a name="817267"> </a>In embedded mode, the application starts up an instance of Derby within the current Java Virtual Machine and shuts down the instance before it completes. No network access is involved. Only one application can access a database at a time. 
-</p>
-<p>In a server environment, the application demonstrates the use of the Derby network client or the IBM DB2 JDBC Universal Driver by connecting to the Network Server and running the demo. Note that the client drivers allow multiple instances of the application to run at the same time.  However, the SQL operations performed by this demo will cause failures when multiple simultaneous instances of the application are run. Use of a client driver to connect to the Network Server in this application is intended only to demonstrate this type of connection. The SimpleApp demo is not suited for simultaneous executions because it creates and drops the table on which it operates.
-</p>
-<h2 class="Heading2"><a name="816689"> </a>What's Included?
-</h2>
- <p class="Body">
-  <a name="816691"> </a>Before running this demo, you should see the following files and directories in the <em class="fileName">/demo/programs/simple</em> directory:
-</p><ul class="Normal">  <li class="Normal"><a name="816694"> </a><em class="fileName">example.html</em>
-
- 
-
-<p class="BodyRelative">
-  <a name="816695"> </a>This file.
-</p>
-  <li class="Normal"><a name="816696"> </a><em class="fileName">
-<a href="SimpleApp.java" target="_top">SimpleApp.java</a></em>
-
- 
-
-<p class="BodyRelative">
-  <a name="816697"> </a>Source code for the example program that starts up Derby, creates a database, performs some inserts and updates, and then shuts down Derby. <em class="Emphasis">Examine this file to see how the application behaves in the various environments</em>.
-</p>
-  <li class="Normal"><a name="816699"> </a><em class="fileName">
-<a href="derby.properties" target="_top">derby.properties</a></em>
-
- 
-
-<p class="BodyRelative">
-  <a name="816700"> </a>Properties file for the Derby system.
+<p>
+  This program is intended to run in Virtual Machines for the Java Platform
+  supporting J2SE 1.4.2 or newer.
+</p>
+<p>
+  In embedded mode, the application starts up an instance of Derby within the
+  current Java Virtual Machine (JVM) and shuts down the instance before it
+  completes. No network access is involved. Only one JVM can access a database
+  at a time.
+</p>
+<p>In a client/server environment, the application demonstrates the
+use of the Derby network client driver or the IBM DB2 JDBC Universal Driver by
+connecting to the Network Server and running the demo. Note that the client
+drivers allow multiple instances of the application to run at the same time.
+However, the SQL operations performed by this demo will cause failures when
+multiple simultaneous instances of the application are run. Use of a client
+driver to connect to the Network Server in this application is intended only to
+demonstrate this type of connection. The SimpleApp demo is not suited for
+simultaneous executions because it creates and drops the table on which it
+operates.
+</p>
+<p>
+  <em>Note that in this document, file paths and environment variables are
+  referenced using UNIX notation unless noted otherwise. This means that if, for
+  example, you are using a Windows platform, you must substitute file separators,
+  path separators and environment variable references to the Windows-specific
+  notation, for example:</em>
+</p>
+<table class="simple">
+  <tr>
+    <td class="heading">Element</td>
+    <td class="heading">Example, UNIX</td>
+    <td class="heading">Example, Windows</td>
+  </tr>
+  <tr>
+    <td class="listItem">File separator</td>
+    <td class="listItem"><em class="fileName">/home/path/file</em></td>
+    <td class="listItem"><em class="fileName">c:\path\file</em></td>
+  </tr>
+  <tr>
+    <td class="listItem">(CLASS)PATH separator</td>
+    <td class="listItem"><var class="envVar">derby.jar:derbytools.jar</var></td>
+    <td class="listItem"><var class="envVar">derby.jar;derbytools.jar</var></td>
+  </tr>
+  <tr>
+    <td class="listItem">Environment Variable reference</td>
+    <td class="listItem"><var class="envVar">$DERBY_HOME</var></td>
+    <td class="listItem"><var class="envVar">%DERBY_HOME%</var></td>
+  </tr>
+</table>
+<p>
+  <em>Also note that this document refers to the JVM launch command as
+    <var class="command">java</var>, and that it is being assumed that the JVM
+    installation's launcher is available via the system's
+    <em class="envVar">PATH</em>. Refer to the documentation of your JVM /
+    runtime environment for details on how to run a Java program using that JVM.
+    </em>
+</p>
+<h3>Modifying the application code</h3>
+<p>
+  If you decide to modify the demo application code, or use it as a model for
+  your own JDBC application, be aware that any change may affect the behavior
+  of the program and the results from running it.
+  For example, the data verification code is very specific to the data this
+  demo inserts into the database, and will not work without modification with
+  other databases.
+</p>
+<p>
+  For more information about how to use Derby, refer to the included
+  documentation and the
+  <a href="http://db.apache.org/derby" target="_new">Apache Derby web site</a>.
+</p>
+<p>
+  If you are relatively new to databases or JDBC,
+  <a href="http://java.sun.com/docs/books/tutorial/jdbc/basics/index.html" target="_new">Sun's
+  JDBC basics tutorial</a> may be a good starting point.
 </p>
-  <li class="Normal"><a name="816701"> </a><em class="fileName">SimpleApp.class</em>
 
- 
 
-<p class="BodyRelative">
-  <a name="816702"> </a>The compiled class file.
-</p>
+<!-- ##########  WHAT'S INCLUDED  ########## -->
+<h2 class="Heading2"><a id="included" name="included">What's Included?</a>
+</h2>
+<p>
+  Before running this demo, you should see the following files and directories
+  in the <em class="fileName">demo/programs/simple/</em> directory:
+</p>
+<ul class="Normal">
+  <li class="Normal"><em class="fileName">example.html</em>
+    <p class="BodyRelative">
+      This file.
+    </p>
+  <li class="Normal"><em class="fileName">
+    <a href="SimpleApp.java" target="_top">SimpleApp.java</a></em>
+    <p class="BodyRelative">
+      Source code for the example program.
+      <em class="Emphasis">Examine this file to see how the application behaves
+      in the various environments</em>.
+    </p>
+  <li class="Normal"><em class="fileName">
+    <a href="derby.properties" target="_top">derby.properties</a></em>
+    <p class="BodyRelative">
+      Properties file for the Derby system. This demo program runs with default
+      settings, but you can use this file to tune Derby if you want to.
+    </p>
+  <li class="Normal"><em class="fileName">SimpleApp.class</em>
+    <p class="BodyRelative">
+      The compiled class file, runnable by Java SE JVMs.
+    </p>
 </ul>
-<p class="Body">
-  <a name="816704"> </a>After running the demo, you will see some new files and directories:
-</p><ul class="Normal">  <li class="Normal"><a name="816706"> </a><em class="fileName">derbyDB</em> (directory)
-
- 
-
-<p class="BodyRelative">
-  <a name="816707"> </a>The directory that makes up the <em class="fileName">derbyDB</em> database. You must not modify anything in this directory, or you will corrupt the database. The directory was created when the application connected with Derby, using the attribute <em class="Emphasis">create=true</em> in the database connection URL. The database name, <em class="Emphasis">derbyDB</em>, was also set in the database connection URL. 
-</p>
-  <li class="Normal"><a name="816712"> </a><em class="fileName">derbyDB\log</em> (directory)
-
- 
-
-<p class="BodyRelative">
-  <a name="816713"> </a>The directory that holds the database transaction logs for the <em class="fileName">derbyDB</em> database. 
-</p>
-  <li class="Normal"><a name="816714"> </a><em class="fileName">derbyDB\seg0</em> (directory)
 
- 
-
-<p class="BodyRelative">
-  <a name="816715"> </a>The directory that holds the data for the <em class="fileName">derbyDB</em> database.
-</p>
-  <li class="Normal"><a name="816716"> </a><em class="fileName">derbyDB\service.properties</em>
-
- 
-
-<p class="BodyRelative">
-  <a name="816717"> </a>An internal file that holds boot-time configuration parameters for the <em class="fileName">derbyDB</em> database; do not edit.
-</p>
-  <li class="Normal"><a name="816719"> </a><em class="fileName">derby.LOG</em>
-
- 
-
-<p class="BodyRelative">
-  <a name="816720"> </a>The log file with Derby progress and error messages.
-</p>
+<p>
+  After running the demo, you will see some new files and directories. These
+  will be located in the directory that the system property
+  <var class="property">derby.system.home</var>
+  points to, or the current directory (<var class="property">user.dir</var>) if
+  <var class="property">derby.system.home</var> is not set for the embedded or
+  Network Server JVM. If you are following the instructions on this page, you
+  will find the new files in the directory
+  <em class="fileName">demo/programs/simple/</em>, relative to this Derby
+  installation. New files are:
+</p>
+<ul class="Normal">
+  <li class="Normal"><em class="fileName">derbyDB</em> (directory)
+    <p class="BodyRelative">
+      The directory that makes up the <em class="fileName">derbyDB</em> database.
+      You must not modify anything in this directory, or you will corrupt the
+      database. The directory was created when the application connected with
+      Derby, using the attribute <em class="Emphasis">create=true</em> in the
+      database connection URL. The database name, <em class="Emphasis">derbyDB</em>,
+      was also set in the database connection URL.
+    </p>
+    <ul class="Normal">
+      <li class="Normal"><em class="fileName">derbyDB/log</em> (directory)
+        <p class="BodyRelative">
+          The directory that holds the database transaction logs for the
+          <em class="fileName">derbyDB</em> database.
+        </p>
+      <li class="Normal"><em class="fileName">derbyDB/seg0</em> (directory)
+        <p class="BodyRelative">
+          The directory that holds the data for the <em class="fileName">derbyDB</em>
+          database.
+        </p>
+      <li class="Normal"><em class="fileName">derbyDB/service.properties</em>
+        <p class="BodyRelative">
+          An internal file that holds boot-time configuration parameters for the
+          <em class="fileName">derbyDB</em> database; do not edit.
+        </p>
+    </ul>
+   <li class="Normal"><em class="fileName">derby.log</em>
+    <p class="BodyRelative">
+      The log file with Derby progress and error messages.
+    </p>
 </ul>
-<h2 class="Heading2"><a name="816722"> </a>How to run this sample application in an embedded environment
+<p>
+  To remove the effects of running the demo program, simply delete the database
+  directory (<em class="fileName">derbyDB</em>) and
+  <em class="fileName">derby.log</em>. Note that if you are running the demo in
+  a client/server environment you most likely need to shut down the Derby
+  Network Server before being able to delete the database directory.
+
+<!-- ##########  HOW TO RUN - EMBEDDED  ########## -->
+<h2 class="Heading2"><a id="runembedded" name="runembedded">How to run this sample application in an embedded environment</a>
 </h2>
- <ol type="1">  <li class="Normal"><a name="816724"> </a>Open a command window.
-  <li class="Normal"><a name="816726"> </a>If you haven't set it already on a system-wide basis, set the DERBY_INSTALL environment variable to the location of the directory where you installed the Derby software in the current command window.
-  <li class="Normal">and change directories to the <em class="fileName">%DERBY_INSTALL%\demo\programs\simple</em> directory.
-  <li class="Normal"><a name="819207"> </a>In the command window, set the CLASSPATH as follows:
-<p>WINDOWS: set CLASSPATH=.;%DERBY_INSTALL%\lib\derby.jar<br>
-UNIX (ksh): export CLASSPATH=.:${DERBY_INSTALL}/lib/derby.jar
-</p>
-<p><table border="4" cellspacing="0" cellpadding="5" bgcolor="#FAF0E6">
-  <caption class="TableTitle"></caption>
-  <tr valign="bottom">
-    <th><a name="819182"> </a><p class="CellHeading">Library or Directory</p></th>
-    <th><a name="819184"> </a><p class="CellHeading">Path to Library or Directory</p></th>
+<p>
+  The Derby embedded driver is a JDBC driver included in binary distributions of
+  Apache Derby, in the directory <em class="fileName">$DERBY_HOME/lib/</em>.
+  The embedded driver should be used when you want to run Derby in the same
+  JVM as your application, for example when no direct network access to the
+  database system is needed.
+</p>
+<table class="listing">
+  <tr>
+    <td class="listItem">Class name:</td>
+    <td class="listItem"><em class="javaObject">org.apache.derby.jdbc.EmbeddedDriver</em></td>
   </tr>
-  <tr valign="top">
-    <td class="DefaultTable"><a name="821049"> </a><p class="CellBody">main Derby library:</p>
-<a name="819190"> </a><p class="CellBody"><em class="fileName">derby.jar</em></p>
-</td>
-    <td class="DefaultTable"><a name="819195"> </a><p class="CellBody"><em class="fileName">%DERBY_INSTALL%\lib\derby.jar</em></p>
-</td>
-  </tr>
-  <tr valign="top">
-    <td class="DefaultTable"><a name="819204"> </a><p class="CellBody">current directory<br>SimpleApp.class</p>
-</td>
-    <td class="DefaultTable"><a name="819206"> </a><p class="CellBody">.\</p>
-</td>
+  <tr>
+    <td class="listItem">Library:</td>
+    <td class="listItem"><em class="fileName">derby.jar</em></td>
   </tr>
 </table>
+<p>&nbsp;</p>
+<ol class="decimal">
+  <li class="Normal">Open a command window.
+  <li class="Normal">If you haven't set it already on a system-wide basis, set
+  the <var class="envVar">DERBY_HOME</var> environment variable to the location
+  of this Derby installation. This is not strictly required to run the demo, but
+  this environment variable will be used later on this page to refer to the
+  required Derby resources, files, etc. Examples:
+    <p class="BodyRelative">UNIX (ksh/bash)</p>
+    <p class="commandLine">export DERBY_HOME=/home/user/derby/db-derby-10.x.y.z-bin</p>
+    <p class="BodyRelative">Windows:</p>
+    <p class="commandLine">set DERBY_HOME=c:\programs\derby\db-derby-10.x.y.z-bin</p>
+  <li class="Normal">Change directories to the <em class="fileName">$DERBY_HOME/demo/programs/simple</em> directory.
+  <li class="Normal">In the command window, set the CLASSPATH to include the
+  current directory (the location of <em class="fileName">SimpleApp.class</em>)
+  and Derby's embedded driver library (<em class="fileName">derby.jar</em>).
+  (You may skip this step and provide the classpath as an option to the JVM
+  launch command instead, refer to your JVM's documentation for details).
+    <p class="BodyRelative">This may be done as follows:</p>
+    <p class="BodyRelative">UNIX (ksh/bash):</p>
+    <p class="commandLine">export CLASSPATH=.:${DERBY_HOME}/lib/derby.jar</p>
+    <p class="BodyRelative">WINDOWS:</p>
+    <p class="commandLine">set CLASSPATH=.;%DERBY_HOME%\lib\derby.jar</p>
+  <li class="Normal">(Optional) Run Derby's Sysinfo utility for testing the
+    classpath for an embedded environment. You should provide the arguments
+    <em class="Emphasis">embedded</em> (to indicate an embedded environment) and
+    <em class="Emphasis">SimpleApp.class</em> to test for the presence of the
+    <em class="javaObject">SimpleApp</em> class.
+    <p class="BodyRelative">
+      You run the utility like this:
+    </p>
+    <p class="CommandLine">
+      java org.apache.derby.tools.sysinfo -cp <em class="Emphasis">arguments</em>
+    </p>
+    <p class="BodyRelative">
+      So for the arguments you need here, run it like this (all on one line):
+    </p>
+    <p class="CommandLine">
+      java org.apache.derby.tools.sysinfo -cp embedded SimpleApp.class
+    </p>
+    <p class="BodyRelative">
+      If your environment is set up correctly, the utility shows output indicating
+      success. It looks like this:
+    </p>
+    <pre class="Output">
+FOUND IN CLASS PATH:
+   Derby embedded engine library (derby.jar)
+   /home/user/derby/db-derby-10.x.y.z-bin/lib/derby.jar
+
+
+   user-specified class (SimpleApp)
+   /home/user/derby/db-derby-10.x.y.z-bin/demo/programs/simple
+
+
+SUCCESS: All Derby related classes found in class path.
+    </pre>
+    <p class="BodyRelative">
+      If something is missing from your classpath environment, the utility
+      indicates what is missing. For example, if you neglected to add the
+      directory containing the SimpleApp class to your classpath, the utility
+      would indicate as such:
+    </p>
+    <pre class="Output">
+FOUND IN CLASS PATH:
+
+   Derby embedded engine library (derby.jar)
+   /home/user/derby/db-derby-10.x.y.z-bin/lib/derby.jar
+
+
+
+NOT FOUND IN CLASS PATH:
+
+   user-specified class (SimpleApp)
+    (SimpleApp not found.)
+    </pre>
+  <li class="Normal">Once you have your environment set up correctly, execute
+    the application from the same directory (<em class="fileName">demo/programs/simple</em>):
+    <p class="CommandLine">java SimpleApp</p>
+    The demo program's default framework is embedded, so there is no need to
+    specify this explicitly.
+    <p class="BodyRelative">A successful run produces the following output:</p>
+    <pre class="Output">
+SimpleApp starting in embedded mode
+Loaded the appropriate driver
+Connected to and created database derbyDB
+Created table location
+Inserted 1956 Webster
+Inserted 1910 Union
+Updated 1956 Webster to 180 Grand
+Updated 180 Grand to 300 Lakeshore
+Verified the rows
+Dropped table location
+Committed the transaction
+Derby shut down normally
+SimpleApp finished
+    </pre>
+    <p class="BodyRelative">
+      If any error messages appear, and you are unable to resolve the error(s),
+      ask for help on the derby-user
+      <a href="http://db.apache.org/derby/derby_mail.html" target="_new">mailing list</a>.
+    </p>
+</ol>
 
-
-</p>
-
-
- 
-
-<p class="BodyRelative">
-  <a name="819218"> </a><p><table border="0" cellpadding="3" cellspacing="2" bgcolor="Silver">
-  <tr valign="top">
-    <td class="BoxTable"><h3 class="BoxHead">
-  <a name="819210"> </a>A note on setting the classpath for an embedded environment
-</h3>
-<a name="819214"> </a><p class="CellBody">Derby provides a script to help you get started with setting the classpath in <br> <em class="fileName">%DERBY_INSTALL%\frameworks\embedded\bin</em>. This script is called<em class="fileName"> setEmbeddedCP </em>and comes in two flavors: one for Windows environment (this file ends with <em class="fileName">.bat</em>) and one for UNIX environments (this file ends with <em class="fileName">.ksh</em>). For users working in those environments, copying the commands in this file will help you get started setting the classpath. </p>
-</td>
+<!-- ##########  HOW TO RUN - CLIENT/SERVER  ########## -->
+<h2 class="Heading2"><a id="runclientserver" name="runclientserver">How to run this sample application in a client/server environment</a>
+</h2>
+<p>You will need to set up both the client process and the server
+process to run the demo application as a client connecting to the Network server.
+The Network Server needs to be running before you can connect using a client
+driver. This demo includes support for both the Derby client driver and the IBM
+DB2 Universal JDBC driver.
+</p>
+<p>You must start the Network Server before trying to run the
+demo application in one of the client modes.
+
+<!-- ##########  HOW TO RUN - SERVER  ########## -->
+<h3><a id="server" name="server">Starting the Network Server</a></h3>
+<ol class="decimal">
+  <li class="Normal">Open a command window for the server.
+  <li class="Normal">If you haven't set it already on a system-wide basis, set
+  the <var class="envVar">DERBY_HOME</var> environment variable to the location of this Derby installation.
+  This is not strictly required to run the demo, but this environment variable
+  will be used later on this page to refer to the required Derby resources,
+  files, etc.
+    <p class="BodyRelative">Examples:</p>
+    <p class="BodyRelative">UNIX (ksh/bash):</p>
+    <p class="commandLine">export DERBY_HOME=/home/user/derby/db-derby-10.x.y.z-bin</p>
+    <p class="BodyRelative">Windows:</p>
+    <p class="commandLine">set DERBY_HOME=c:\programs\derby\db-derby-10.x.y.z-bin</p>
+  <li class="Normal">Change directories to the <em class="fileName">$DERBY_HOME/demo/programs/simple</em> directory.
+  <li class="Normal">In the command window for the server, start the Network Server
+  by running the executable jar file <em class="fileName">derbyrun.jar</em>.
+    <p class="BodyRelative">Examples:</p>
+    <p class="BodyRelative">UNIX (ksh/bash):
+    <p class="commandLine">java -jar $DERBY_HOME/lib/derbyrun.jar server start</p>
+    <p class="BodyRelative">Windows:</p>
+    <p class="commandLine">java -jar %DERBY_HOME%\lib\derbyrun.jar server start</p>
+    <p class="BodyRelative">When the server starts, the server console output will
+      resemble something like this:
+    </p>
+    <pre class="Output">
+Security manager installed using the Basic server security policy.
+Apache Derby Network Server - &lt;version&gt; - (&lt;svnrevision&gt;) started and ready to accept connections on port 1527 at &lt;timestamp&gt;
+    </pre>
+    <p class="BodyRelative">(When you are done with the demo, you may shut down the network server for example by
+      passing the arguments <var class="command">server shutdown</var> to
+      <em class="fileName">derbyrun.jar</em> in a new command window.)
+    </p>
+  <table cellSpacing=2 cellPadding=3 bgColor=silver border=0>
+    <tbody>
+      <tr vAlign=top>
+        <td class=BoxTable>
+        <h3 class=BoxHead>A note on running the Network Server</h3>
+        <p class=CellBodySmall>You may start the server in a number of other ways,
+        including:</p>
+        <ul class="boxed">
+          <li>Invoking the Network Server's main class from the command line.
+            <p class="CommandLine">java -cp $DERBY_HOME/lib/derbynet.jar org.apache.derby.drda.NetworkServerControl start</p>
+            <li>Accessing the <em class="java">NetworkServerControl</em> API from a Java program.
+          <li>Running a so-called "embedded server" by setting the property
+            <var class="property">derby.drda.startNetworkServer=true</var> before loading the
+            embedded driver (with <em class="fileName">derbynet.jar</em> in the classpath).
+          <li>Running the script <em class=fileName>$DERBY_HOME/bin/startNetworkServer</em>
+            (<em class=fileName>%DERBY_HOME%\bin\startNetworkServer.bat</em> on Windows).
+        </ul>
+        <p class="CellBody">
+        Note that unless you set the system property
+        <var class="property">derby.system.home</var>, Derby's default database
+        location is the working directory of the Network Server JVM.
+        </p>
+        </td>
+      </tr>
+    </tbody>
+  </table>
+</ol>
+
+<!-- ##########  HOW TO RUN - DERBY CLIENT  ########## -->
+<h3><a id="derbyclient" name="derbyclient">Using the Derby client driver (<var class="command">derbyclient</var>)</a></h3>
+<p>
+  The Derby client driver is a JDBC driver included in binary distributions of
+  Apache Derby, in the directory <em class="fileName">$DERBY_HOME/lib/</em>.
+  It is recommended that you use this driver to connect to the
+  Derby Network Server, as this client driver is developed and maintained by
+  the Apache Derby development community.
+</p>
+<table class="listing">
+  <tr><td class="listItem">Class name:</td><td class="listItem"><em class="javaObject">org.apache.derby.jdbc.ClientDriver</em></td></tr>
+  <tr><td class="listItem">Library:</td><td class="listItem"><em class="fileName">derbyclient.jar</em></td></tr>
+</table>
+<p>&nbsp;</p>
+<ol class="decimal">
+  <li class="Normal">Open a command window
+  <li class="Normal">If you haven't set it already on a system-wide basis, set
+  the <var class="envVar">DERBY_HOME</var> environment variable to the location
+  of this Derby installation. This is not strictly required to run the demo, but
+  this environment variable will be used later on this page to refer to the
+  required Derby resources, files, etc. Examples:
+    <p class="BodyRelative">UNIX (ksh/bash):</p>
+    <p class="commandLine">export DERBY_HOME=/home/user/derby/db-derby-10.x.y.z-bin</p>
+    <p class="BodyRelative">Windows:</p>
+    <p class="commandLine">set DERBY_HOME=c:\programs\derby\db-derby-10.x.y.z-bin</p>
+  <li class="Normal">Change directories to the <em class="fileName">$DERBY_HOME/demo/programs/simple</em> directory.
+  <li class="Normal">In the client command window, set the CLASSPATH to include the
+  current directory (the location of <em class="fileName">SimpleApp.class</em>)
+  and Derby's client driver library (<em class="fileName">derbyclient.jar</em>).
+  (You may skip this step and provide the classpath as an option to the JVM
+  launch command instead, refer to your JVM's documentation for details).
+    <p class="BodyRelative">This may be done as follows:</p>
+    <p class="BodyRelative">UNIX (ksh/bash):</p>
+    <p class="commandLine">export CLASSPATH=.:${DERBY_HOME}/lib/derbyclient.jar</p>
+    <p class="BodyRelative">WINDOWS:</p>
+    <p class="commandLine">set CLASSPATH=.;%DERBY_HOME%\lib\derbyclient.jar</p>
+  <li class="Normal">(Optional) Run Derby's Sysinfo utility for testing the
+    classpath in your environment. You should provide the arguments
+    <em class="Emphasis">client</em> (to indicate a client environment) and
+    <em class="Emphasis">SimpleApp.class</em> to test for the presence of the
+    <em class="javaObject">SimpleApp</em> class.
+    <p class="BodyRelative">
+      You run the utility like this:
+    </p>
+    <p class="CommandLine">
+      java org.apache.derby.tools.sysinfo -cp <em class="Emphasis">arguments</em>
+    </p>
+    <p class="BodyRelative">
+      So for the arguments you need here, run it like this (all on one line):
+    </p>
+    <p class="CommandLine">
+      java org.apache.derby.tools.sysinfo -cp client SimpleApp.class
+    </p>
+    <p class="BodyRelative">
+      If your environment is set up correctly, the utility shows output indicating
+      success. It looks like this:
+    </p>
+    <pre class="Output">
+FOUND IN CLASS PATH:
+
+   Derby Client libraries (derbyclient.jar)
+   /home/user/derby/db-derby-10.x.y.z-bin/lib/derbyclient.jar
+
+
+   user-specified class (SimpleApp)
+   /home/user/derby/db-derby-10.x.y.z-bin/demo/programs/simple
+
+
+SUCCESS: All Derby related classes found in class path.
+    </pre>
+  <li class="Normal">Start the Derby Network Server in a different command
+    window, as described <a href="#server">here</a>
+  <li class="Normal">Start SimpleApp in Derby client mode:
+    <p class="commandLine">java SimpleApp derbyclient</p>
+    <p class="BodyRelative">The <var class="command">derbyclient</var> argument
+      tells the program to use the Derby client driver instead of its default
+      driver (the embedded driver).
+    </p>
+    <p class="BodyRelative">A successful run produces the following output:</p>
+    <pre class="Output">
+SimpleApp starting in derbyclient mode
+Loaded the appropriate driver
+Connected to and created database derbyDB
+Created table location
+Inserted 1956 Webster
+Inserted 1910 Union
+Updated 1956 Webster to 180 Grand
+Updated 180 Grand to 300 Lakeshore
+Verified the rows
+Dropped table location
+Committed the transaction
+SimpleApp finished
+    </pre>
+    <p class="BodyRelative">
+      If any error messages appear, and you are unable to resolve the error(s),
+      ask for help on the derby-user
+      <a href="http://db.apache.org/derby/derby_mail.html" target="_new">mailing list</a>.
+    </p>
+</ol>
+
+<!-- ##########  HOW TO RUN - DB2 UNIVERSAL (JCC) DRIVER  ########## -->
+<h3><a id="jcc" name="jcc">Using the IBM DB2 JDBC Universal Driver (<var class="command">jccjdbcclient</var>)</a></h3>
+<p>
+  In version 10.0 of Derby, the IBM DB2 JDBC Universal Driver (also known as
+  JCC) was the only client driver that could communicate with the Derby Network
+  Server. This driver is not licensed under the
+  <a href="http://www.apache.org/licenses/">Apache License, Version 2.0</a> used
+  by Apache Derby, but can be downloaded from the IBM developerWorks website
+  (see: <a href="http://www-106.ibm.com/developerworks/db2/downloads/jcc/" target="_new">IBM
+  DB2 JDBC Universal Driver for Apache Derby Network Server</a> for more
+  information).
+</p>
+<table class="listing">
+  <tr>
+    <td class="listItem">Class name:</td>
+    <td class="listItem"><em class="javaObject">com.ibm.db2.jcc.DB2Driver</em></td>
+  </tr>
+  <tr>
+    <td class="listItem">Libraries:</td>
+    <td class="listItem"><em class="fileName">db2jcc.jar</em></td>
+  <tr>
+    <td class="listItem"></td>
+    <td class="listItem"><em class="fileName">db2jcc_license_c.jar</em></td>
   </tr>
 </table>
-</p>
-
-</p>
-  <li class="Normal"><a name="819222"> </a>Run Derby's Sysinfo utility for testing the classpath for an embedded environment. You will provide the arguments <em class="Emphasis">embedded</em> to indicate an embedded environment and <em class="Emphasis">SimpleApp.class</em> to test for the presence of the <em class="javaObject">SimpleApp</em> class.
-
- 
-
-<p class="BodyRelative">
-  <a name="818908"> </a>You run the utility like this:
-</p>
-<p class="CommandLine"><a name="818909">java org.apache.derby.tools.sysinfo -cp <em class="Emphasis">arguments</em></a></p>
- 
-
-<p class="BodyRelative">
-  <a name="818907"> </a>So for the arguments you need here, run it like this (all on one line):
-</p>
-<p class="CommandLine"><a name="818910">java org.apache.derby.tools.sysinfo -cp embedded SimpleApp.class</a></p>
- 
-
-<p class="BodyRelative">
-  <a name="820871"> </a>If your environment is set up correctly, the utility shows output indicating success. It looks like this:
-</p>
-<p class="OutputRelative"><a name="820884"> </a>FOUND IN classpath:</p>
-<p class="OutputRelative"><a name="820886"> </a>  Derby embedded engine library (derby.jar)</p>
-<p class="OutputRelative"><a name="820887"> </a></p>
-<p class="OutputRelative"><a name="820893"> </a>   user-specified class (SimpleApp)</p>
-<p class="OutputRelative"><a name="820896"> </a>SUCCESS: All Derby-Related classes for embedded environment found in classpath.</p>
-
- 
-
-<p class="BodyRelative">
-  <a name="820878"> </a>If something is missing from your classpath environment, the utility indicates what is missing. For example, if you neglected to add the directory containing the SimpleApp class to your classpath, the utility would indicate as such:
-</p>
-<p class="OutputRelative"><a name="820925"> </a>Testing for presence of Derby-related libraries for embedded environment.</p>
-<p class="OutputRelative"><a name="820927"> </a>FOUND IN classpath:</p>
-<p class="OutputRelative"><a name="820956"> </a></p>
-<p class="OutputRelative"><a name="820929"> </a>   Derby embedded engine library (derby.jar)</p>
-<p class="OutputRelative"><a name="820934"> </a></p>
-<p class="OutputRelative"><a name="820937"> </a>NOT FOUND IN classpath:</p>
-<p class="OutputRelative"><a name="820958"> </a>   user-specified class (SimpleApp)</p>
-<p class="OutputRelative"><a name="820940"> </a>    (SimpleApp not found.)</p>
-  <li class="Normal"><a name="818903"> </a>Once you have your environment set up correctly, execute the application in embedded mode from the same directory (<em class="fileName">/demo/programs/simple</em>): 
-<p class="CommandLine"><a name="816737">java SimpleApp</a></p></ol>
-
-
-<BLOCKQUOTE><A name=820970></A>SimpleApp starting in embedded mode. <BR>
-<A 
-name=820971></A>Loaded the appropriate driver. <BR>
-<A name=820972></A>Connected 
-to and created database derbyDB <BR>
-<A name=820973></A>Created table derbyDB 
-<BR>
-<A name=820974></A>Inserted 1956 Webster <BR>
-<A name=820975></A>Inserted 
-1910 Union <BR>
-<A name=820976></A>Updated 1956 Webster to 180 Grand <BR>
-<A 
-name=820977></A>Updated 180 Grand to 300 Lakeshore <BR>
-<A 
-name=820978></A>Verified the rows <BR>
-<A name=820979></A>Dropped table derbyDB 
-<BR>
-<A name=820980></A>Closed result set and statement <BR>
-<A 
-name=820981></A>Committed transaction and closed connection <BR>
-<A 
-name=820982></A>Database shut down normally <BR>
-<A name=818289></A>SimpleApp 
-finished</BLOCKQUOTE>
-
-
-
-
-<h2 class="Heading2"><a name="816723"> </a>How to run this sample application in a server environment
-</h2>
-<p>You will need to set up both the client process and the server process to run the demo application as a client connecting to the Network server.</p>
-<P><A name="Server"><B>First start the Network Server:</B></A></P>
-
- <ol type="1">  <li class="Normal"><a name="816724"> </a>Open a command window for the server.
-  <li class="Normal"><a name="816726"> </a>If you haven't set it already on a system-wide basis, set the DERBY_INSTALL environment variable to the location of the directory where you installed the Derby software in the current command window.
-<li class="Normal">Change directories to the <em class="fileName">\demo\programs\simple</em> directory.
-  <li class="Normal"><a name="819207"> </a>In the command window for the server, set the CLASSPATH as follows:<p>
-
-<BLOCKQUOTE>WINDOWS: set CLASSPATH=.;%DERBY_INSTALL%\lib\derby.jar;%DERBY_INSTALL%\lib\derbynet.jar<BR>
-UNIX (ksh): export CLASSPATH=.:${DERBY_INSTALL}/lib/derby.jar:${DERBY_INSTALL}/lib/derbynet.jar</BLOCKQUOTE>
-<BLOCKQUOTE>
-<br>
-
-<TABLE cellspacing="0" cellpadding="5" bgcolor="#faf0e6" border="4">
-  <CAPTION class=TableTitle>Classpath for the process starting the Network Server </CAPTION>
-  <TBODY>
-    <TR vAlign=bottom>
-      <TH><A name=819182></A>
-      <P class=CellHeading>Library or Directory</P>
-      </TH>
-      <TH><A name=819184></A>
-      <P class=CellHeading>Path to Library or Directory</P>
-      </TH>
-    </TR>
-    <TR vAlign=top>
-      <TD class=DefaultTable><A name=821049></A>
-      <P class=CellBody>main Derby library:</P>
-      <A name=819190></A>
-      <P class=CellBody><EM class=fileName>derby.jar</EM></P>
-      </TD>
-      <TD class=DefaultTable><A name=819195></A>
-      <P class=CellBody><EM 
-        class=fileName>%DERBY_INSTALL%\lib\derby.jar</EM></P>
-      </TD>
-    </TR>
-    <TR vAlign=top>
-      <TD class=DefaultTable><A name=821050></A>
-      <P class=CellBody>Derby Network Server:</P>
-      <A name=819200></A>
-      <P class=CellBody><EM class=fileName>derbynet.jar</EM></P>
-      </TD>
-      <TD class=DefaultTable><A name=819205></A>
-      <P class=CellBody><EM 
-        class=fileName>%DERBY_INSTALL%\lib\derbynet.jar</EM></P>
-      </TD>
-    </TR>
-  </TBODY>
-</TABLE>
-  <BR>
-  <TABLE cellSpacing=2 cellPadding=3 bgColor=silver border=0>
-    <TBODY>
-      <TR vAlign=top>
-        <TD class=BoxTable>
-        <H3 class=BoxHead><A name=819210></A>A note on setting the classpath for 
-        a server environment</H3>
-        <A name=819214></A>
-        <P class=CellBody>Derby provides a script to help you get started with 
-        setting the classpath in <BR>
-        <EM 
-        class=fileName>%DERBY_INSTALL%\frameworks\NetworkServer\bin</EM>. This 
-        script is called <EM class=fileName>setNetworkServerCP</EM> and comes in 
-        two flavors: one for Windows environment (this file ends with <EM 
-        class=fileName>.bat</EM>) and one for UNIX environments (this file ends 
-        with <EM class=fileName>.ksh</EM>). For users working in those environments using the Derby Network Server,
-      copying the commands in this file will help you get started setting the
-      classpath on the server process. </P>
-        </TD>
-      </TR>
-    </TBODY>
-  </TABLE>
-</BLOCKQUOTE>
-  <LI class="Normal">Run Derby's Sysinfo utility for testing the classpath for a server environment.
-  You will provide the arguments <EM 
-  class=Emphasis>server</EM> to indicate a server environment and <EM 
-  class=Emphasis>SimpleApp.class</EM> to test for the presence of the <EM 
-  class=javaObject>SimpleApp</EM> class.
-  <BR>
-  If your environment is set up correctly, the utility shows output indicating success. It looks like this:<BR>
-  <BR>
-  java org.apache.derby.tools.sysinfo -cp server SimpleApp.class<BR><br>
-FOUND IN CLASS PATH:<BR>
-<BR>
-   <BLOCKQUOTE>
-Derby Network Server library (derbynet.jar)<BR>
-<BR>
-<BR>
-  user-specified class (SimpleApp)</BLOCKQUOTE>
-<BR>
-<BR>
-  SUCCESS: All Derby related classes found in class path.<BR>
-  <LI class="Normal"><A name=816724></A>Now start the Network Server:<BR>
-  <A name=818909>java org.apache.derby.drda.NetworkServerControl start</A><BR>
-  <BLOCKQUOTE>A sucessful start produces the following output:</BLOCKQUOTE>
-<BLOCKQUOTE>
-<BLOCKQUOTE><CODE>Server is ready to accept connections on port 1527.</CODE></BLOCKQUOTE>
-</BLOCKQUOTE>
-
-</OL>
-<P <A name="derbyClient"><B>Next run the SimpleApp demo in Derby client mode:</B></P>
-<OL type=1>
-  <LI class=Normal value=1><A name=816724></A>Open a command window to run the application in client mode
-  <LI class="Normal"><A name=816724></A>If you haven't set it already on a system-wide basis, set the DERBY_INSTALL
-  environment variable for the current command window to the location of
-  the directory where you installed the Derby software 
-  <LI class="Normal"><A name=816724></A>Change directories to the %DERBY_INSTALL%<EM class=fileName>\demo\programs\simple</EM> directory.
-  <LI class="Normal"><A name=816724></A>In the command window for the client, set the CLASSPATH as follows:
-<BLOCKQUOTE>WINDOWS: set CLASSPATH=.;%DERBY_INSTALL%\lib\derbyclient.jar<BR>
-UNIX (ksh): export CLASSPATH=.:${DERBY_INSTALL}/lib/derbyclient.jar</BLOCKQUOTE>
-<BLOCKQUOTE>
-<TABLE cellSpacing=0 cellPadding=5 bgColor=#faf0e6 border=4>
-  <CAPTION class=TableTitle>Classpath for the client process when using the Derby network client</CAPTION>
-  <TBODY>
-    <TR vAlign=top>
-      <TD class=DefaultTable><A name=821950></A>
-      <P class=CellBody>Derby network client:</P>
-      <A name=819200></A>
-      <P class=CellBody><EM class=fileName>derbyclient.jar</EM></P>
-      </TD>
-      <TD class=DefaultTable><A name=819305></A>
-      <P class=CellBody><EM 
-        class=fileName>%DERBY_INSTALL%\lib\derbyclient.jar</EM></P>
-      </TD>
-    </TR>
-    <TR vAlign=top>
-      <TD class=DefaultTable><A name=819204></A>
-      <P class=CellBody>current directory<BR>SimpleApp.class</P>
-      </TD>
-      <TD class=DefaultTable><A name=819206></A>
-      <P class=CellBody>.\</P>
-      </TD>
-    </TR>
-  </TBODY>
-</TABLE>
-</BLOCKQUOTE>
-  <LI class="Normal">Run Derby's Sysinfo utility for testing the classpath for a client environment.
-  You will provide the arguments <EM 
-  class=Emphasis>client</EM> to indicate a client environment and <EM 
-  class=Emphasis>SimpleApp.class</EM> to test for the presence of the <EM 
-  class=javaObject>SimpleApp</EM> class. Note that the following assumes you have not downloaded the IBM
-  DB2 JDBC Universal Driver (see the next section for details) so the db2jcc.jar
-  is listed as NOT FOUND - this is not a problem.<BR>
-  If your environment is set up correctly, the utility shows output indicating success. It looks like this:<BR>
-  <BR>
-  java org.apache.derby.tools.sysinfo -cp client SimpleApp.class<BR>
-FOUND IN CLASS PATH:<BR>
-<BR><BLOCKQUOTE>
-   Derby Client libraries (derbyclient.jar)<BR>
-<BR>
-<BR>
-  user-specified class (SimpleApp)</BLOCKQUOTE>
-  <BR>
-NOT FOUND IN CLASS PATH:<BR>
-<BR><BLOCKQUOTE>
-   Derby Client libraries (db2jcc.jar)<BR>
-  (com.ibm.db2.jcc.DB2Driver not found.)</BLOCKQUOTE>
-<BR>
-  <LI class="Normal"><A name=816724></A>Now start the SimpleApp in Derby client mode:<BR>
-  <br><A name=818909>java SimpleApp derbyclient</A><BR>
-  <BR>
-  <A name=818687></A>A successful run produces the following output:
-  <P><A name=820970></A>SimpleApp starting in derbyclient mode.<BR>
-  Loaded the appropriate driver.<BR>
-  Connected to and created database derbyDB<BR>
-  Created table derbyDB<BR>
-  Inserted 1956 Webster<BR>
-  Inserted 1910 Union<BR>
-  Updated 1956 Webster to 180 Grand<BR>
-  Updated 180 Grand to 300 Lakeshore<BR>
-  Verified the rows<BR>
-  Dropped table derbyDB<BR>
-  Closed result set and statement<BR>
-  Committed transaction and closed connection<BR>
-  SimpleApp finished</P>
-</OL>
-<P><B>Running the SimpleApp demo using the IBM DB2 JDBC Universal Driver:</B></P>
-<P>In version 10.0 of Derby, the IBM DB2 JDBC Universal Driver was the only client driver
-that could communicate with the Derby Network Server. This driver is not licensed under the <a href="http://www.apache.org/licenses/">Apache License, Version 2.0</a> used by Apache Derby, but can be downloaded from the IBM developerWorks
-website (see: <A href="http://www-106.ibm.com/developerworks/db2/downloads/jcc/">IBM 
-      DB2 JDBC Universal Driver, for Apache Derby Network Server</A> for more information). Beginning with version 10.1, the Derby network client driver is bundled with the Derby distribution and this is the recommended client driver for most applications. The DB2 Universal Driver is still supported and can be utilized with the SimpleApp demo as follows (these instructions assume you have unzipped the Universal Driver into the <EM>lib</EM> directory of <EM>DERBY_INSTALL</EM>):</P>
-<OL type="1">
-  <LI class=Normal value=1><A name=JccSteps></A>Open a command window to run the application in client mode using the DB2
-  Universal Driver
-  <LI class="Normal"><A name=JccSteps></A>If you haven't set it already on a system-wide basis, set the DERBY_INSTALL
-  environment variable for the current command window to the location of
-  the directory where you installed the Derby software. It is assumed that you
-  installed the IBM DB2 JDBC Universal Driver jar in the lib subdirectory
-  at this location.
-  <LI class="Normal"><A name=JccSteps></A>Change directories to the %DERBY_INSTALL%<EM class=fileName>\demo\programs\simple</EM> directory.
-  <li class="Normal"><a href="#Server">Set the Network Server classpath</a> as you would if using the Derby network client.
-  <LI class="Normal"><A name=JccSteps></A>In the command window for the client, set the classpath as follows:
-<BLOCKQUOTE>WINDOWS: set CLASSPATH=.;%DERBY_INSTALL%\lib\db2jcc.jar;%DERBY_INSTALL%\lib\db2jcc_license_c.jar<BR>
-UNIX (ksh): export CLASSPATH=.:${DERBY_INSTALL}/lib/db2jcc.jar:${DERBY_INSTALL}/lib/db2jcc_license_c.jar</BLOCKQUOTE>
-<BLOCKQUOTE>
-<TABLE cellSpacing=0 cellPadding=5 bgColor=#faf0e6 border=4>
-  <CAPTION class=TableTitle>Classpath for the client process when using the IBM DB2 JCC Client Driver</CAPTION>
-  <TBODY>
-    <TR vAlign=top>
-      <TD class=DefaultTable><A name=821950></A>
-      <P class=CellBody>IBM DB2 JCC Client Driver jar files:</P>
-      <A 
-        name=819200></A>
-      <P class=CellBody><EM class=fileName>db2jcc.jar</EM> and <EM 
-        class=fileName>db2jcc_license_c.jar</EM></P>
-      </TD>
-      <TD class=DefaultTable><A name=819305></A>
-      <P class=CellBody><EM 
-        class=fileName>%DERBY_INSTALL%\lib\db2jcc_license_c.jar</EM><BR>
-      <EM 
-        class=fileName>%DERBY_INSTALL%\lib\db2jcc.jar</EM></P>
-      </TD>
-    </TR>
-    <TR vAlign=top>
-      <TD class=DefaultTable><A name=819204></A>
-      <P class=CellBody>current directory<BR>
-      SimpleApp.class</P>
-      </TD>
-      <TD class=DefaultTable><A name=819206></A>
-      <P class=CellBody>.\</P>
-      </TD>
-    </TR>
-  </TBODY>
-</TABLE>
-</BLOCKQUOTE>
-  <LI class="Normal"><A name=JccSteps></A>Now start the SimpleApp demo in Derby client mode:<BR><br>
-  <A name=818909>java SimpleApp jccjdbcclient</A>
- </OL>
-<BLOCKQUOTE><A name=818687></A></BLOCKQUOTE>
-<BLOCKQUOTE>A successful run produces the following output:<BR>
-</BLOCKQUOTE>
-<BLOCKQUOTE>SimpleApp starting in jccjdbc mode.<BR>
-Loaded the appropriate driver.<BR>
-Connected to and created database derbyDB<BR>
-Created table derbyDB<BR>
-Inserted 1956 Webster<BR>
-Inserted 1910 Union<BR>
-Updated 1956 Webster to 180 Grand<BR>
-Updated 180 Grand to 300 Lakeshore<BR>
-Verified the rows<BR>
-Dropped table derbyDB<BR>
-Closed result set and statement<BR>
-Committed transaction and closed connection<BR>
-SimpleApp finished</BLOCKQUOTE>
-<BR>
-<TABLE cellSpacing=2 cellPadding=3 bgColor=silver border=0>
-    <TBODY>
-      <TR vAlign=top>
-        <TD class=BoxTable>
-        <H3 class=BoxHead><A name=819210></A>A note on setting the classpath for a client environment (JCC)</H3>
-        <A name=819214></A>
-        <P class=CellBody>Derby provides a script to help you get started with setting the IBM DB2
-      JDBC Universal Driver client classpath: <BR>
-        <EM 
-        class=fileName>%DERBY_INSTALL%\frameworks\NetworkServer\bin</EM>. This 
-        script is called <EM class=fileName>setNetworkClientCP</EM> and comes in 
-        two flavors: one for Windows environment (this file ends with <EM 
-        class=fileName>.bat</EM>) and one for UNIX environments (this file ends 
-        with <EM class=fileName>.ksh</EM>). For users working in those environments using the IBM DB2 JCC Client
-      Driver Client, copying the commands in this file will help you get started
-      setting the classpath on the client process. Note to use these scripts
-      copy the jar files into the <EM 
-        class=fileName>%DERBY_INSTALL%\lib </EM>directory.</P>
-        </TD>
-      </TR>
-    </TBODY>
-  </TABLE>
-  <P class=NavBarVersion>Apache Derby Version 10.1</P>
+<p>
+  Newer versions of Derby include <a href="#derbyclient">Derby's own network
+  client driver</a>, which is the recommended client driver for most applications.
+  The DB2 Universal Driver is still supported and can be utilized with the
+  SimpleApp demo as follows (these instructions assume you have unzipped the
+  Universal Driver libraries into the <em class="fileName">lib</em> directory of
+  <var class="envVar">DERBY_HOME</var>):
+</p>
+<ol class="decimal">
+  <li class="Normal">Open a command window
+  <li class="Normal">If you haven't set it already on a system-wide basis, set
+  the <var class="envVar">DERBY_HOME</var> environment variable to the location
+  of this Derby installation. This is not strictly required to run the demo, but
+  this environment variable will be used later on this page to refer to the
+  required Derby resources, files, etc. Examples:
+    <p class="BodyRelative">UNIX (ksh/bash):</p>
+    <p class="commandLine">export DERBY_HOME=/home/user/derby/db-derby-10.x.y.z-bin</p>
+    <p class="BodyRelative">Windows:</p>
+    <p class="commandLine">set DERBY_HOME=c:\programs\derby\db-derby-10.x.y.z-bin</p>
+  <li class="Normal">Change directories to the <em class="fileName">$DERBY_HOME/demo/programs/simple</em> directory.
+  <li class="Normal">In the jcc client command window, set the CLASSPATH to include the
+  current directory (the location of <em class="fileName">SimpleApp.class</em>)
+  and the JCC libraries (<em class="fileName">db2jcc.jar</em> and
+  <em class="fileName">db2jcc_license_c.jar</em>).
+  (You may skip this step and provide the classpath as an option to the JVM
+  launch command instead, refer to your JVM's documentation for details).
+    <p class="BodyRelative">This may be done as follows:</p>
+    <p class="BodyRelative">UNIX (ksh/bash):</p>
+    <p class="commandLine">
+      export CLASSPATH=.:${DERBY_HOME}/lib/db2jcc.jar:${DERBY_HOME}/lib/db2jcc_license_c.jar
+    </p>
+    <p class="BodyRelative">WINDOWS:</p>
+    <p class="commandLine">
+      set CLASSPATH=.;%DERBY_HOME%\lib\db2jcc.jar;%DERBY_HOME%\lib\db2jcc_license_c.jar
+    </p>
+    <p class="BodyRelative">
+      It is assumed that you installed the IBM DB2 JDBC Universal Driver jars in
+      the <em class="fileName">lib</em> subdirectory of this Derby installation
+      (<var class="envVar">DERBY_HOME</var>).
+    </p>
+  <li class="Normal">Start the Derby Network Server in a different command
+    window, as described <a href="#server">here</a>
+  <li class="Normal">Start the SimpleApp demo in JCC client mode:
+    <p class="commandLine">
+      java SimpleApp jccjdbcclient
+    </p>
+    <p class="BodyRelative">The <var class="command">jccjdbcclient</var> argument
+      tells the program to use the IBM DB2 JDBC Universal driver (JCC) instead
+      of its default driver (the embedded driver).
+    </p>
+    <p class="BodyRelative">A successful run produces the following output:</p>
+    <pre class="Output">
+SimpleApp starting in jccjdbc mode
+Loaded the appropriate driver
+Connected to and created database derbyDB
+Created table location
+Inserted 1956 Webster
+Inserted 1910 Union
+Updated 1956 Webster to 180 Grand
+Updated 180 Grand to 300 Lakeshore
+Verified the rows
+Dropped table location
+Committed the transaction
+SimpleApp finished
+    </pre>
+ </ol>
+
+<!-- ##########  FOOTER (VERSION INFO)  ########## -->
+<hr>
+<p class=NavBarVersion>Last updated for Apache Derby Version 10.3.2</p>
 
 </body>
 </html>



Mime
View raw message