db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From myrn...@apache.org
Subject svn commit: r596792 - in /db/derby/code/trunk: java/demo/ java/demo/simplemobile/ tools/release/
Date Tue, 20 Nov 2007 19:29:38 GMT
Author: myrnavl
Date: Tue Nov 20 11:29:37 2007
New Revision: 596792

URL: http://svn.apache.org/viewvc?rev=596792&view=rev
Log:
DERBY-3190 - new SimpleMobileApp Demo for Java ME platforms. 
  Patch contributed by John H. Embretsen

Added:
    db/derby/code/trunk/java/demo/simplemobile/
    db/derby/code/trunk/java/demo/simplemobile/SimpleMobileApp.java   (with props)
    db/derby/code/trunk/java/demo/simplemobile/readme.html   (with props)
Modified:
    db/derby/code/trunk/java/demo/build.xml
    db/derby/code/trunk/java/demo/csfull.css
    db/derby/code/trunk/java/demo/demo.html
    db/derby/code/trunk/java/demo/navbar.html
    db/derby/code/trunk/tools/release/build.xml

Modified: db/derby/code/trunk/java/demo/build.xml
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/demo/build.xml?rev=596792&r1=596791&r2=596792&view=diff
==============================================================================
--- db/derby/code/trunk/java/demo/build.xml (original)
+++ db/derby/code/trunk/java/demo/build.xml Tue Nov 20 11:29:37 2007
@@ -74,6 +74,7 @@
         <pathelement location="${jcc}"/>
       </classpath>
     </javac>
+    <!-- "simple" demos under java/demo/ (SimpleApp, SimpleMobileApp) -->
     <javac
       source="1.4"
       target="1.4"
@@ -85,8 +86,9 @@
       optimize="${optimize}"
       proceed="${proceed}"
       verbose="${verbose}"
-      srcdir="${derby.demo.src.dir}/simple"
-      destdir="${out.dir}">
+      srcdir="${derby.demo.src.dir}"
+      destdir="${out.dir}"
+      includes="simple/**,simplemobile/**">
       <classpath>
         <pathelement location="${javasrc.dir};${jcc}"/>
         <pathelement path="${java14compile.classpath};${jcc}"/>

Modified: db/derby/code/trunk/java/demo/csfull.css
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/demo/csfull.css?rev=596792&r1=596791&r2=596792&view=diff
==============================================================================
--- db/derby/code/trunk/java/demo/csfull.css (original)
+++ db/derby/code/trunk/java/demo/csfull.css Tue Nov 20 11:29:37 2007
@@ -329,6 +329,11 @@
 	background-color : transparent;
 }
 
+OL.decimal {
+        background-color : transparent;
+        list-style-type : decimal;
+}
+
 P {
 	text-align : left;
 	font-style : normal;

Modified: db/derby/code/trunk/java/demo/demo.html
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/demo/demo.html?rev=596792&r1=596791&r2=596792&view=diff
==============================================================================
--- db/derby/code/trunk/java/demo/demo.html (original)
+++ db/derby/code/trunk/java/demo/demo.html Tue Nov 20 11:29:37 2007
@@ -28,10 +28,14 @@
 the <A href="../../docs/html/adminguide/index.html">Apache Derby Server and Administration
Guide</A> 
 .</p>
 <UL>
-	<LI><A href="simple/example.html">Simple</A>
+<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>
-</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
+    insert, modify and retreive some data.</p>
+</li>
 <LI><A href="nserverdemo/readme.html">Network Server Sample Programs</A>
 	<p class="BodyRelative">Two examples are provided to demonstrate how to obtain an
<em class="Emphasis">embedded connection</em> 
 and <em class="Emphasis">client connections</em> using the Network Server to
connect to the same database. 
@@ -44,9 +48,9 @@
 The document describes the tables, the names and types of columns in those tables, and the
constraints, indexes, and triggers in the database.
     </p>
 </li>
-	<LI><A href="workingwithderby/readme.html">Getting Started With Derby</A>
+<LI><A href="workingwithderby/readme.html">Getting Started With Derby</A>
         <p class="BodyRelative">Programs described and modified as part of the activities
documented in 
-the <A href="../../docs/html/getstart/index.html">Getting Started With Derby</A>
manual.</p></LI>
+the <A href="../../docs/html/getstart/index.html">Getting Started With Derby</A>
manual.</p>
 </LI>
 </UL>
 

Modified: db/derby/code/trunk/java/demo/navbar.html
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/demo/navbar.html?rev=596792&r1=596791&r2=596792&view=diff
==============================================================================
--- db/derby/code/trunk/java/demo/navbar.html (original)
+++ db/derby/code/trunk/java/demo/navbar.html Tue Nov 20 11:29:37 2007
@@ -25,6 +25,7 @@
 
 <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>

Added: db/derby/code/trunk/java/demo/simplemobile/SimpleMobileApp.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/demo/simplemobile/SimpleMobileApp.java?rev=596792&view=auto
==============================================================================
--- db/derby/code/trunk/java/demo/simplemobile/SimpleMobileApp.java (added)
+++ db/derby/code/trunk/java/demo/simplemobile/SimpleMobileApp.java Tue Nov 20 11:29:37 2007
@@ -0,0 +1,379 @@
+/*
+
+   Derby - Class SimpleMobileApp
+
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+
+ */
+
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import org.apache.derby.jdbc.EmbeddedSimpleDataSource;  // from derby.jar
+
+/**
+ * <p>This sample program is a small JDBC application showing how to use and
+ * access Derby in a mobile (Java ME, formerly known as J2ME) environment.
+ * </p>
+ * <p>Instructions for how to run this program are given in 
+ * <A HREF=example.html>readme.html</A> located in the same directory as this
+ * source file by default.
+ *
+ * <p>Derby supports <em>embedded</em> access in a mobile Java environment

+ * provided that the Java Virtual Machine supports all of the following:
+ * </p>
+ * <ul>
+ *   <li>Connected Device Configuration (CDC) 1.1 (JSR-218)</li>
+ *   <li>Foundation Profile (FP) 1.1 (JSR-219) or better</li>
+ *   <li>JDBC Optional package (JSR-169) for Java ME platforms</li>
+ * </ul>
+ * 
+ * <p>(Older versions of Derby may support older versions of the above mentioned
+ * specifications. Please refer to release notes or ask on the derby-user
+ * mailing list for details.)
+ * </p>
+ * <p>The main difference between accessing a database in a Java ME environment
+ * as opposed to a Java SE or EE environment is that the JSR-169 specification
+ * does not include the <code>java.sql.DriverManager</code> class. However, 
+ * Derby provides a DataSource class that can be used to obtain connections to 
+ * Derby databases: <code>org.apache.derby.jdbc.EmbeddedSimpleDataSource</code>.
+ * This is demonstrated in this simple demo application.
+ * </p>
+ * <p>To compile this application on your own, make sure you include both
+ * derby.jar and the location (directory) of the compiled version of this source
+ * file in the compiler's classpath.
+ * </p>
+ */
+public class SimpleMobileApp {
+
+    /**
+     * <p>To run this application run your Java launcher with derby.jar and 
+     * this class is the classpath. Any arguments to this class will be ignored.
+     * </p>
+     * <p>Example:
+     * </p>
+     * <p>
+     * <code>&lt;mobileJvm&gt; -cp .:$DERBY_HOME/lib/derby.jar SimpleMobileApp</code>
+     * </p>
+     * <p>The application will exit with an error if no JDBC (JSR-169 or better) 
+     * support is detected.
+     * </p>
+     * 
+     * @param args No arguments required. Any supplied arguments will be ignored.
+     */
+    public static void main(String[] args) {
+        
+        SimpleMobileApp demo = new SimpleMobileApp();
+        if (vmSupportsJSR169()) {
+            demo.runDemo();
+        } else {
+            System.err.println("No valid JDBC support detected in this JVM. If "
+                    + "you are running a Java ME (CDC) JVM, make sure support "
+                    + "for the JSR-169 optional package is available to the "
+                    + "JVM. Otherwise, make sure your JVM supports JDBC 3.0 or "
+                    + "newer.\n");
+            System.exit(1);
+        }
+        System.out.println("SimpleMobileApp finished");
+    }
+    
+    private void runDemo() {
+        
+        System.out.println("SimpleMobileApp started");
+        
+        /* If we are using a Java ME (CDC/Foundation) JVM, 
+         * we need to use a DataSource to obtain connections to our
+         * database, because java.sql.DriverManager is not available.
+         * 
+         * When using JVMs supporting Java SE we can use either 
+         * java.sql.DriverManager or a Datasource to obtain connections. 
+         * 
+         * If we were to use a DataSource for Java SE, we could use
+         * the org.apache.derby.jdbc.EmbeddedDataSource, rather than the
+         * org.apache.derby.jdbc.EmbeddedSimpleDataSource that we need to 
+         * use for Java ME.
+         */
+        
+        EmbeddedSimpleDataSource ds = new EmbeddedSimpleDataSource();
+        
+        /*
+         * The connection specifies "create" in the DataSource settings for
+         * the database to be created when connecting for the first time. 
+         * 
+         * To remove the database, remove the directory simpleMobileDB and its 
+         * contents.
+         * 
+         * The directory simpleMobileDB will be created in the directory that 
+         * the system property <code>derby.system.home</code> points to, or the
+         * current directory (<code>user.dir</code>) if derby.system.home is
not
+         * set.
+         */
+        
+        String dbName = "simpleMobileDB"; // the name of the database
+        ds.setDatabaseName(dbName);
+        // tell Derby to create the database if it does not already exist
+        ds.setCreateDatabase("create"); 
+        
+        /* We will be using Statement and PreparedStatement objects for 
+         * executing SQL. These objects are resources that should be released 
+         * explicitly after use, hence the try-catch-finally pattern below.
+         */
+        Connection conn = null;
+        Statement s = null;
+        PreparedStatement ps = null;
+        ResultSet rs = null;    // used for retreiving the results of a query
+        try {
+            /* By default, the schema APP will be used when no username is 
+             * provided.
+             * Otherwise, the schema name is the same as the user name.
+             * If you want to use a different schema, or provide a username and
+             * password for other reasons, you can connect using:
+             * 
+             *   Connection conn = ds.getConnection(username, password);
+             * or use the
+             *    setUser(String) and setPassword(String) methods of
+             * EmbeddedSimpleDataSource.
+             * 
+             * 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 = ds.getConnection();
+            System.out.println("Connected to and created database " + dbName);
+            
+            /* Creating a statement object that we can use for running various
+             * SQL statements commands against the database.*/
+            s = conn.createStatement();
+
+            // autoCommit is on by default
+            
+            /* Create a table... */
+            s.execute("create table streetaddr(num int, addr varchar(40))");
+            System.out.println("Created table streetaddr");
+            
+            // Insert some rows...
+            s.execute("insert into streetaddr values (1956,'Webster St.')");
+            System.out.println("Inserted 1956 Webster");
+            s.execute("insert into streetaddr values (1910,'Union St.')");
+            System.out.println("Inserted 1910 Union");
+            
+            // Update some rows...
+            
+            /* It is recommended to use PreparedStatements whenever 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).
+             */
+            
+            // use this PreparedStatement for updating a row identified by num
+            ps = conn.prepareStatement(
+                    "update streetaddr set num=?, addr=? where num=?");
+            
+            // update one row...
+            ps.setInt(1, 180);
+            ps.setString(2, "Grand Ave.");
+            ps.setInt(3, 1956);
+            ps.executeUpdate();
+            System.out.println("Updated 1956 Webster to 180 Grand");
+
+            // update another row...
+            ps.setInt(1, 300);
+            ps.setString(2, "Lakeshore Ave.");
+            ps.setInt(3, 180);
+            ps.execute();
+            System.out.println("Updated 180 Grand to 300 Lakeshore");
+
+            // Select the rows and verify some of the results...
+            rs = s.executeQuery("SELECT num, addr FROM streetaddr ORDER BY num");
+
+            // Verification: Number of rows and sorted contents of the num column
+            boolean correctResults = true;
+            if (!rs.next())
+            {
+                System.err.println("No rows in table! (ResultSet was empty)");
+                correctResults = false;
+            } else {
+                int num;
+                int rows = 0;
+                do {
+                    rows++;
+                    num = rs.getInt(1);
+                    if ((rows == 1) && (num != 300)) {
+                        System.err.println("Wrong first row returned! "
+                                + "Expected num = 300, but got " + num);
+                        correctResults = false;
+                    } else if ((rows == 2) && (num != 1910)) {
+                        System.err.println("Wrong second row returned! "
+                        + "Expected num = 1910, but got " + num);
+                        correctResults = false;
+                    }
+                } while (rs.next());
+                if (rows !=2) {
+                    System.err.println("Wrong number of rows in ResultSet "
+                        + "(streetaddr table): " + rows);
+                    correctResults = false;
+                }
+            }
+
+            if (correctResults) {
+                System.out.println("Verified the rows");
+            } else {
+                System.out.println("Verification failed: Wrong results!");
+            }
+
+            /* This demo automatically drops the table. This way the demo can
+             * be run the same way multiple times. If you want the data to
+             * stay in the database, comment out the following Statement
+             * execution and recompile the class.
+             */
+            s.execute("drop table streetaddr");
+            System.out.println("Dropped table streetaddr");
+            
+            // shut down the database
+            /* In embedded mode, an application should shut down the database.
+             * If the application fails to shut down the database explicitly,
+             * the Derby does not perform a checkpoint when the JVM shuts down, 
+             * which means that the next connection will be slower because
+             * Derby has to perform recovery operations.
+             * Explicitly shutting down the database using the appropriate 
+             * data source property is recommended.
+             * This style of shutdown will always throw an SQLException, but in
+             * this case the exception is (usually) not an indication that 
+             * something went wrong.
+             */
+             try {
+                 ds.setShutdownDatabase("shutdown");
+                 ds.getConnection();
+             } catch (SQLException se) {
+                 if (!( (se.getErrorCode() == 45000) 
+                         && ("08006".equals(se.getSQLState()) ))) {
+                    // if the error code or SQLState is different, we have an
+                    // unexpected exception (shutdown failed)
+                    printSQLException(se);
+                    se.printStackTrace();
+                 } else {
+                     System.out.println(dbName + " shut down successfully");
+                 }
+             }
+
+        } catch (SQLException e) {
+            printSQLException(e);
+        } finally {
+            // release all open resources to avoid unnecessary memory usage
+            
+            // ResultSet
+            try {
+                if (rs != null) {
+                    rs.close();
+                    rs = null;
+                }
+            } catch (SQLException sqle) {
+                printSQLException(sqle);
+            }
+            
+            // Statement
+            try {
+                if (s != null) {
+                    s.close();
+                    s = null;
+                }
+            } catch (SQLException sqle) {
+                printSQLException(sqle);
+            }
+            
+            //PreparedStatement
+            try {
+                if (ps != null) {
+                    ps.close();
+                    ps = null;
+                }
+            } catch (SQLException sqle) {
+                printSQLException(sqle);
+            }
+
+            //Connection
+            try {
+                if (conn != null) {
+                    conn.close();
+                    conn = null;
+                }
+            } catch (SQLException sqle) {
+                printSQLException(sqle);
+            }
+        }
+    }
+    
+    /**
+     * Prints information about an SQLException to System.err.
+     * Use this information to debug the problem.
+     * 
+     * @param e Some SQLException which info should be printed
+     */
+    public static void printSQLException(SQLException e) {
+
+        do {
+            System.err.println("\n----- SQLException caught: -----");
+            System.err.println("  SQLState:   " + e.getSQLState());
+            System.err.println("  Error Code: " + e.getErrorCode());
+            System.err.println("  Message:    " + e.getMessage());
+            //e.printStackTrace(System.err); // enable and recompile to get more info
+            System.err.println();
+            e = e.getNextException();
+        } while (e != null);
+    }
+    
+   /**
+    * Checks if this Java Virtual Machine includes support for the JDBC optional
+    * package for CDC platforms (JSR-169), or better (JDBC 3.0 or newer), by
+    * checking the availability of classes or interfaces introduced in or
+    * removed from specific versions of JDBC-related specifications.
+    * 
+    * @return true if the required JDBC support level is detected, false 
+    *         otherwise.
+    */
+    public static boolean vmSupportsJSR169() {
+        if (haveClass("java.sql.Savepoint")) {
+            /* New in JDBC 3.0, and is also included in JSR-169.
+             * JSR-169 is a subset of JDBC 3 which does not include the Driver 
+             * interface.
+             * See http://wiki.apache.org/db-derby/VersionInfo for details.
+             */
+            return true;
+        } else {
+            return false;
+        }
+    }
+    
+   /**
+    * Checks if this JVM is able to load a specific class. May for instance
+    * be used for determining the level of JDBC support available.
+    * @param className Fully qualified name of class to attempt to load.
+    * @return true if the class can be loaded, false otherwise.
+    */
+   private static boolean haveClass(String className) {
+       try {
+           Class.forName(className);
+           return true;
+       } catch (Exception e) {
+           return false;
+       }
+   }
+
+}

Propchange: db/derby/code/trunk/java/demo/simplemobile/SimpleMobileApp.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: db/derby/code/trunk/java/demo/simplemobile/readme.html
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/demo/simplemobile/readme.html?rev=596792&view=auto
==============================================================================
--- db/derby/code/trunk/java/demo/simplemobile/readme.html (added)
+++ db/derby/code/trunk/java/demo/simplemobile/readme.html Tue Nov 20 11:29:37 2007
@@ -0,0 +1,330 @@
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+  <head>
+    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+    <meta name="LASTUPDATED" content="2007-11-09 16:00:00 CET">
+    <link rel="StyleSheet" href="../csfull.css" type="text/css" media="screen">
+    <title>Simple Java ME Database Application</title>
+  </head>
+  <body>
+    <h1 class="Title">Simple Java ME Database Application</h1>
+    <p class="Body">
+      More Derby demos and sample programs are available from <a href="../readme.html"
target="_top">../readme.html</a>   
+    </p>
+    <ul class="ChapterTOC">
+        <li class="ChapterTOC"><a href="#overview">Overview</a></li>
+        <li class="ChapterTOC"><a href="#requirements">Requirements</a></li>
+        <li class="ChapterTOC"><a href="#included">What's Included?</a></li>
+        <li class="ChapterTOC"><a href="#run">How to run this sample application</a></li>
+        <li class="ChapterTOC"><a href="#results">Results</a></li>
+        <li class="ChapterTOC"><a href="#modify">How to modify this sample application</a></li>
+    </ul>
+    
+    <!-- ###############  OVERVIEW  ############### -->
+    <h2 class="Heading2"><a name="overview">Overview</a></h2>
+    <p class="Body">
+      This document describes <em class="fileName">SimpleMobileApp</em>, an 
+      example of a small Java application using JDBC to create and
+      work with a Derby database. The demo is designed to run on small devices such
+      as advanced cell phones or smart phones. Such devices must include support
+      for the Java Platform, Micro Edition (Java ME, previously known as J2ME) 
+      CDC/Foundation Profile; see 
+      <a href="#requirements">specific requirements below</a>. This program:
+    </p>
+    <ul class="Normal">  
+      <li class="Normal">runs on Java ME or SE Virtual Machines</li>
+      <li class="Normal">runs Derby in embedded mode (the database engine runs in the
same JVM as the program)</li>
+      <li class="Normal">creates an appropriate data source for connecting to Derby</li>
+      <li class="Normal">creates a new database</li>
+      <li class="Normal">creates a table in the database</li>
+      <li class="Normal">inserts some data</li>
+      <li class="Normal">updates some data</li>
+      <li class="Normal">selects data, then verifies some of it</li>
+      <li class="Normal">drops the table</li>
+      <li class="Normal">disconnects</li>
+      <li class="Normal">shuts down the database</li>
+    </ul>
+    <p class="Body">
+      Inspect the source code (<em class="fileName">SimpleMobileApp.java</em>)
to
+      see how this demo application actually works.
+    </p>
+    
+    
+    <!-- ###############  REQUIREMENTS  ############### -->
+    <h2 class="Heading2"><a name="requirements">Requirements</a></h2>
+    <p class="Body">
+      In order to run this demo, you need a Java Runtime Environment with access
+      to the compiled class (<em class="fileName">SimpleMobileApp.class</em>)
+      and the Derby embedded driver jar file (<em class="fileName">derby.jar</em>).
+    </p>
+    <p>
+      This demo is designed to demonstrate database access from a mobile Java environment.
+      If you are using a Java ME (J2ME) Virtual Machine, and Derby version 10.3 or newer,
+      the following minimum requirements must be met:
+    </p>
+    <ul>
+      <li>Connected Device Configuration (CDC) 1.1 (JSR-218)</li>
+      <li>Foundation Profile 1.1 (JSR-219)</li>
+      <li>JDBC Optional package (JSR-169) for Java ME platforms</li>
+    </ul>
+    <p>
+      If you are using a Java SE Virtual Machine and the pre-compiled version
+      of this demo, and/or Derby 10.3 or newer, your JVM must support Java version
+      1.4.2 or newer.
+    </p>
+    
+    <!-- ###############  CONVENTIONS  ############### -->
+    <h2 class="Heading2"><a name="conventions">Conventions</a></h2>
+    <p class="Body">
+      Conventions used in this document:
+    </p>
+    <ul>
+      <li>
+        <p class="BodyRelative">
+          <strong>File paths</strong> use forward slash (/) as the file separator,

+          as used in UNIX-like operating systems. You will have to substitute this 
+          for the file separator used by your operating system if this is different
+          from the forward slash.
+        </p>
+        <p class="BodyRelative">
+          For example, if the path to a file is described as <em class="fileName">derby/lib/derby.jar</em>,
+          this would correspond to <em class="fileName">derby\lib\derby.jar</em>
+          on a Microsoft Windows operating system.
+        </p>
+      </li>
+      <li>
+        <p class="BodyRelative">
+          The notation used for <strong>environment variables</strong> is the
UNIX standard
+          notation in most shells, that is $VARIABLE for the variable named VARIABLE. 
+          On Microsoft Windows operating systems, $VARIABLE must be replaced with %VARIABLE%.

+          For example, replace <em class="fileName">$DERBY_HOME/lib/derby.jar</em>
with
+            <em class="fileName">%DERBY_HOME%\lib\derby.jar</em> on Windows XP.
+        </p>
+        <p class="BodyRelative">
+          To check the value of a given environment variable, use the echo command in
+          a command window, for example:
+        </p>
+        <p class="CommandLine">
+          echo $DERBY_HOME
+        </p>
+        <p class="BodyRelative">or</p>
+        <p class="CommandLine">
+          echo %DERBY_HOME%
+        </p>
+      </li>
+    </ul>
+    
+    <!-- ###############  WHAT'S INCLUDED  ############### -->
+    <h2 class="Heading2"><a name="included">What's Included?</a></h2>
+    <p class="Body">
+      Before running this demo, you should see the following files and directories
+      in the <em class="fileName">$DERBY_HOME/demo/programs/simplemobile/</em>
directory:
+    </p>
+    <ul class="Normal">
+      <li class="Normal"><em class="fileName">readme.html</em>
+        <p class="BodyRelative">
+          This file.
+        </p>
+      </li>
+      <li class="Normal"><em class="fileName"><a href="SimpleMobileApp.java"
target="_top">SimpleMobileApp.java</a></em>
+        <p class="BodyRelative">
+          Source code for this sample program. Examine this
+          file to see how the application works.
+        </p>
+      </li>
+      <li class="Normal"><em class="fileName">SimpleMobileApp.class</em>
+        <p class="BodyRelative">
+          The compiled class file, runnable in a supported Java Virtual Machine.
+        </p>
+      </li>
+    </ul>
+
+    <!-- ###############  HOW TO RUN  ############### -->
+    <h2 class="Heading2"><a name="run">How to run this sample application</a></h2>
+    <p>
+      Unless noted otherwise, the example commands shown are (UNIX) bash shell commands.

+      See <a href="#conventions">conventions used in this document</a> for details
on
+      how to adapt the example commands to other systems.
+    </p>
+    <ol class="decimal">
+      <li class="Normal"><strong>Open a new terminal/shell/console/command window.</strong></li>
+      <li class="Normal">
+        <p class="BodyRelative"><strong>If you haven't set it already on a system-wide
basis, set the DERBY_HOME 
+        environment variable to the location of the directory where you installed Derby.</strong></p>
+        <p class="BodyRelative">Example - UNIX, bash:</p>
+        <p class="CommandLine">
+          export DERBY_HOME=/home/user/derby/derby-bin-install
+        </p>
+        <p class="BodyRelative">Example - Windows XP:</p>
+        <p class="CommandLine">
+          set DERBY_HOME=c:\derby\derby-bin-install
+        </p>
+      </li>
+      <li class="Normal"><strong>Change directories to the <em class="fileName">$DERBY_HOME/demo/programs/simplemobile</em>
directory.</strong>
+        <p class="CommandLine">
+          cd $DERBY_HOME/demo/programs/simplemobile/
+        </p>
+      </li>
+      <li class="Normal"><strong>In the command window, set the CLASSPATH to
include 
+        the current directory (containing <em class="fileName">SimpleMobileApp.class</em>)
+        and derby.jar.</strong>
+        <p class="BodyRelative">Example - UNIX, bash:</p>
+        <p class="CommandLine">
+          export CLASSPATH=.:$DERBY_HOME/lib/derby.jar
+        </p>
+        <p class="BodyRelative">Example - Windows XP:</p>
+        <p class="CommandLine">
+          set CLASSPATH=.;%DERBY_HOME%\lib\derby.jar
+        </p>
+        <p class="BodyRelative">
+          Note that some JVMs do not read the value of the CLASSPATH environment
+          variable. If that is the case with your JVM, you must specify the 
+          classpath as part of the JVM launch command used in the next step. 
+          Refer to your JVM's documentation for details.          
+        </p>
+      </li>
+      <li class="Normal"><strong>Execute the application.</strong>
+        <p class="CommandLine">
+          &lt;vmExecutable&gt; SimpleMobileApp
+        </p>
+        <p class="BodyRelative">
+          Replace &lt;vmExecutable&gt; with the appropriate launch command (including
+          any necessary options) for your JVM. Here is an example showing how to
+          execute the demo with a phoneME Advanced JVM without built-in support
+          for JDBC/JSR-169, in a linux environment:
+        </p>
+        <p class="CommandLine">
+          cvm -Xbootclasspath/a:$JDBC_JARS/jsr169.jar -cp $CLASSPATH SimpleMobileApp
+        </p>
+      </li>
+    </ol>
+    
+    <!-- ###############  RESULTS  ############### -->
+    <h2 class="Heading2"><a name="results">Results</a></h2>
+    <h3 class="heading4">Console output:</h3>
+    <blockquote class="Output">
+        SimpleMobileApp started<br>
+        Connected to and created database simpleMobileDB<br>
+        Created table streetaddr<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 streetaddr<br>
+        simpleMobileDB shut down successfully<br>
+        SimpleMobileApp finished<br>
+    </blockquote>
+    <p class="Body">
+        If any of the <a href="#requirements">requirements</a> are not fulfilled,
the application
+        may fail with an error message. If you are unable to resolve this error, ask for
+        help on the derby-user <a href="http://db.apache.org/derby/derby_mail.html" target="_new">mailing
list</a>.
+    </p>
+    
+    <h3 class="heading4">New files:</h3>
+    <p class="Body">
+      After running the demo, you will see some new files and directories in 
+      <em class="fileName">$DERBY_HOME/demo/programs/simplemobile/</em>:
+    </p>
+    <ul class="Normal">
+      <li class="Normal"><em class="fileName">simpleMobileDB</em> (directory)
+        <p class="BodyRelative">
+          The directory that makes up the <em class="fileName">simpleMobileDB</em>
database. 
+          If you intend to use this database again, you must not modify anything in 
+          this directory, or you will corrupt the database. 
+          The directory was created when the application connected with Derby, 
+          having set the DataSource property for creating a database. The database name,

+          <em class="Emphasis">simpleMobileDB</em>, was also set as the value
of a 
+          DataSource property. 
+        </p>
+        <ul class="Normal">
+          <li class="Normal"><em class="fileName">simpleMobileDB/log</em>
(directory)
+            <p class="BodyRelative">
+              The directory that holds the database transaction logs for the 
+              <em class="fileName">simeplMobileDB</em> database. 
+            </p>
+          </li>
+          <li class="Normal"><em class="fileName">simpleMobileDB/seg0</em>
(directory)
+            <p class="BodyRelative">
+              The directory that holds the data for the <em class="fileName">simpleMobileDB</em>
database.
+            </p>
+          </li>
+          <li class="Normal"><em class="fileName">simpleMobileDB/service.properties</em>
+            <p class="BodyRelative">
+              An internal file that holds boot-time configuration parameters for the 
+              <em class="fileName">simpleMobileDB</em> database; do not edit.
+            </p>
+          </li>
+        </ul>
+      </li>
+      <li class="Normal"><em class="fileName">derby.log</em>
+        <p class="BodyRelative">
+          The log file with Derby progress and error messages.
+        </p>
+      </li>
+    </ul>
+    <p class="Body">
+      Note that since the application normally drops (deletes) the table
+      it created when done processing the data, the database will be empty when
+      the application has finsished running. To view or modify the contents of the
+      database yourself, <a href="#modify">modify the application</a> accordingly.
+    </p>
+
+    <h3 class="heading4">Cleaning up:</h3>
+    <p class="Body">
+      To delete the files created by running the demo application, simply delete
+      the database directory (<em class="fileName">simpleMobileDB</em>) and the
+      Derby log file (<em class="fileName">derby.log</em>). These files should
be 
+      located in the directory from which you executed the demo program, normally
+      <em class="fileName">$DERBY_HOME/demo/programs/simpledemo/</em>.
+    </p>
+  
+  <!-- ###############  HOW TO MODIFY  ############### -->
+  <h2 class="Heading2"><a name="modify">How to modify this sample application</a></h2>
+  <p class="Body">
+    To change the behavior of this demo, for example if you want the program not
+    to delete the table when data processing has finished, you may do the following:
+  </p>
+  <ol class="decimal">
+    <li class="Normal"><strong>Open the source file (<em class="fileName">SimpleMobileApp.java</em>)
+      in your favorite Java source editor.</strong>
+      <p class ="BodyRelative">(You may want to create a backup copy of the source
file before continuing.)</p>
+    </li>
+    <li class="Normal">
+      <p class="BodyRelative"><strong>Modify the Java source according to your
desires, 
+        then save the file.</strong></p>
+    <li class="Normal"><strong>Compile the modified source.</strong> 
+      Make sure that the generated class file is supported by your runtime environment 
+      (for example, CDC 1.1 is based on J2SE 1.4). You also need to include
+      <em class="fileName">derby.jar</em> in the compiler's classpath.
+      <p class="BodyRelative">Example - UNIX, bash - JDK 6:</p>
+      <p class="CommandLine">
+        javac -source 1.4 -target 1.4 -classpath $DERBY_HOME/lib/derby.jar SimpleMobileApp.java
+      </p>
+    </li>
+  </ol>
+  <p class="Body">A new version of the demo, <em class="fileName">SimpleMobileApp.class</em>,
+  is now ready for use.</p>
+  
+  <hr>
+  <!-- ###############  VERSION INFO  ############### -->
+  <p class=NavBarVersion>Last updated for Apache Derby Version 10.3.2</p>
+
+</body>
+</html>

Propchange: db/derby/code/trunk/java/demo/simplemobile/readme.html
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: db/derby/code/trunk/tools/release/build.xml
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/tools/release/build.xml?rev=596792&r1=596791&r2=596792&view=diff
==============================================================================
--- db/derby/code/trunk/tools/release/build.xml (original)
+++ db/derby/code/trunk/tools/release/build.xml Tue Nov 20 11:29:37 2007
@@ -167,6 +167,8 @@
                   fullpath="${derby.bin}/demo/templates/server.policy"/>
       <zipfileset dir="${basedir}/classes" includes="SimpleApp.class"
                   prefix="${derby.bin}/demo/programs/simple"/>
+      <zipfileset dir="${basedir}/classes" includes="SimpleMobileApp.class"
+                  prefix="${derby.bin}/demo/programs/simplemobile"/>            
       <zipfileset dir="${basedir}/classes" includes="SimpleNetwork*.class"
                   prefix="${derby.bin}/demo/programs/nserverdemo"/>
       <zipfileset dir="${basedir}/classes/nserverdemo" includes="*.class"
@@ -216,6 +218,8 @@
                   fullpath="${derby.bin}/demo/templates/server.policy"/>
       <tarfileset dir="${basedir}/classes" includes="SimpleApp.class"
                   prefix="${derby.bin}/demo/programs/simple"/>
+      <tarfileset dir="${basedir}/classes" includes="SimpleMobileApp.class"
+                  prefix="${derby.bin}/demo/programs/simplemobile"/>
       <tarfileset dir="${basedir}/classes" includes="SimpleNetwork*.class"
                   prefix="${derby.bin}/demo/programs/nserverdemo"/>
       <tarfileset dir="${basedir}/classes/nserverdemo" includes="*.class"



Mime
View raw message