db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fuzzylo...@apache.org
Subject svn commit: r164630 [3/3] - in /incubator/derby/code/trunk/java/demo: ./ nserverdemo/ simple/
Date Mon, 25 Apr 2005 19:29:38 GMT
Modified: incubator/derby/code/trunk/java/demo/nserverdemo/readme.html
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/demo/nserverdemo/readme.html?rev=164630&r1=164629&r2=164630&view=diff
==============================================================================
--- incubator/derby/code/trunk/java/demo/nserverdemo/readme.html (original)
+++ incubator/derby/code/trunk/java/demo/nserverdemo/readme.html Mon Apr 25 12:29:37 2005
@@ -1,26 +1,26 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
-<HTML>
-<HEAD><META http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
-<TITLE>Example Programs</TITLE>
-<link rel="stylesheet" type="text/css" href="../csfull.css" title="sample">
-</HEAD>
-<BODY>
-
-<H1>Overview</H1>
-<p>The following example scenarios show you 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.</p>
-
-<p>An embedded connection is a connection to a database that is booted in the same JVM as the application. This connection can be obtained after the Derby Embedded driver is booted. The URL prefix is jdbc:derby:</p>
-
-<p>Client applications that require a database connection across the network use the network server protocol (DRDA) to connect to the Network Server. This type of connection is referred to as a client connection. The URL prefix is jdbc:derby:net:</p>
-<UL>
-</LI>
-<LI><p class="BodyRelative">First scenario: <A href="simpleserversample.html">Simple Network Server Sample</A></p>
-	<p class="BodyRelative">This example uses two programs to illustrate how a typical client program that starts up in its own JVM can connect to the Network Server that the server program starts. The client program (SimpleNetworkClientSample) and the server program (SimpleNetworkServerSample) each run in their own (different) JVMs. The example shows the Derby jar files that are needed at the client side and server side to use the Network Server. The SimpleNetworkClientSample program also shows how to use the DriverManger or a DataSource to obtain client connections.</p></LI></LI>
-</LI>
-<LI><p class="BodyRelative">Second scenario: <A href="nserverdemo.html">Network Server Demo </A></p>
-	<p class="BodyRelative">This example program (NsSample) starts the network server and shows how to obtain client and embedded connections using the Network Server to connect to the same database, all in one JVM.</p></LI></LI>
-</LI>
-</UL>
-
-</BODY>
-</HTML>
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<HTML>
+<HEAD><META http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+<TITLE>Example Programs</TITLE>
+<link rel="stylesheet" type="text/css" href="../csfull.css" title="sample">
+</HEAD>
+<BODY>
+
+<H1>Overview</H1>
+<p>The following example scenarios show you 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.</p>
+
+<p>An embedded connection is a connection to a database that is booted in the same JVM as the application. This connection can be obtained after the Derby Embedded driver is booted. The URL prefix is jdbc:derby:</p>
+
+<p>Client applications that require a database connection across the network use the network server protocol (DRDA) to connect to the Network Server. This type of connection is referred to as a client connection. The URL prefix is jdbc:derby:net:</p>
+<UL>
+</LI>
+<LI><p class="BodyRelative">First scenario: <A href="simpleserversample.html">Simple Network Server Sample</A></p>
+	<p class="BodyRelative">This example uses two programs to illustrate how a typical client program that starts up in its own JVM can connect to the Network Server that the server program starts. The client program (SimpleNetworkClientSample) and the server program (SimpleNetworkServerSample) each run in their own (different) JVMs. The example shows the Derby jar files that are needed at the client side and server side to use the Network Server. The SimpleNetworkClientSample program also shows how to use the DriverManger or a DataSource to obtain client connections.</p></LI></LI>
+</LI>
+<LI><p class="BodyRelative">Second scenario: <A href="nserverdemo.html">Network Server Demo </A></p>
+	<p class="BodyRelative">This example program (NsSample) starts the network server and shows how to obtain client and embedded connections using the Network Server to connect to the same database, all in one JVM.</p></LI></LI>
+</LI>
+</UL>
+
+</BODY>
+</HTML>

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

Modified: incubator/derby/code/trunk/java/demo/nserverdemo/simpleserversample.html
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/demo/nserverdemo/simpleserversample.html?rev=164630&r1=164629&r2=164630&view=diff
==============================================================================
--- incubator/derby/code/trunk/java/demo/nserverdemo/simpleserversample.html (original)
+++ incubator/derby/code/trunk/java/demo/nserverdemo/simpleserversample.html Mon Apr 25 12:29:37 2005
@@ -1,153 +1,153 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
-<html>
-
-<head>
-<META http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
-<title>Derby Network Server Simple sample program</title>
-</head>
-
-<body>
-
-<h2>Simple Derby Network Server Example</h2>
-
-<h2>Overview</h2>
-
-<p>The primary purpose of this example is to demonstrate how to obtain an embedded
-connection and client connections using the Network Server to the same
-database. This program shows how to use either the DriverManager or a
-DataSource to obtain client connections. </p>
-
-<p>In order for a database to be consistent, only one JVM is allowed to access
-it at a time. The embedded driver is loaded when the Network Server is started.
-Hence, the JVM that starts the Network Server can get an embedded connection to
-the same database that Network Server is accessing to serve the clients from
-other JVMs. This solution allows you to take advantage of the performance
-benefits of the embedded driver as well as allow for client connections from other
-JVMs to connect to the same database.</p>
-
-<p>In this example, the following two programs show how to setup the server and
-client programs when interacting with the Network Server.</p>
-
-<p>SimpleNetworkServerSample.java:
-This program starts the Derby Network Server as well as the embedded
-driver and waits for clients to connect.</p>
-
-<p>SimpleNetworkClientSample.java:
-This is the client program that interacts with the Derby Network Server
-from another JVM.</p>
-
-<h3>SimpleNetworkServerSample program</h3>
-
-<p>In particular, this program:</p>
-
-<ul>
- <li>starts the Derby Network Server using a property and also loads the embedded driver</li>
- <li>checks if the Derby Network Server is up and running</li>
- <li>creates the database 'NSSimpleDB' if not already created </li>
- <li>obtains an embedded database connection</li>
- <li>tests the database connection by executing a sample query</li>
- <li>allows for client connections to connect to the server until the user decides to stop the server and exit the program</li>
- <li>closes the connection</li>
- <li>shuts down the Derby
-     Network Server before exiting the program.</li>
-</ul>
-
-<p>The following files should be installed in the <font style=italic>%DERBY_INSTALL%</font><tt><span>\demo\programs\nserverdemo\</span></tt> directory in
-order to run this sample program:</p>
-
-<ul>
- <li> Source file:</li>
- <ul>
-  <li><tt>SimpleNetworkServerSample.java</tt></li>
- </ul>
- <li>Compiled class file:</li>
- <ul>
-  <li><tt>SimpleNetworkServerSample.class</tt></li>
- </ul>
-</ul>
-
-<h2>How to run the SimpleNetworkServerSample program</h2>
-
-<p>To run this simple Derby Network Server sample program:</p>
-
-<ol>
- <li>Open a command prompt and change directories to the <span class=italic>%DERBY_INSTALL%</span>\demo\programs\nserverdemo
-     directory, where <span class=italic>%DERBY_INSTALL%</span> is the directory
-     where you installed Derby.</li>
- <li>Set the CLASSPATH to include the following jar files in order to run this
-     program.</li>
-<ul><li>the current directory (".")</li>
-<li><tt>derbynet.jar</tt>: <BR>The Network Server jar file. It must be in your CLASSPATH since we start the Network Server in this program.</li>
-<li><tt>derby.jar</tt>: <BR>The Derby database engine jar file.</li>
-</ul>
-
-<li>Test the CLASSPATH settings by running the following java command:
-
-<pre>java org.apache.derby.tools.sysinfo</pre>
-
-<p>This command will show the Derby jar files that are in the CLASSPATH. </p></li>
-
-<li>Once you have set up your environment correctly, execute the application from the <br><span class=italic>%DERBY_INSTALL%</span>\demo\programs\nserverdemo directory:
-
-<pre>java SimpleNetworkServerSample</pre>
-</li></ol>
-<p>You should receive output similar to the following if the program runs successfully:</p>
-<tt>Starting Network Server<br>Testing if Network Server is up and running!<br>Derby Network Server now running<br><span>Got an embedded connection.</span><br>Testing embedded connection by executing a sample query<br><span>number</span> of rows in <span>sys.systables</span> = 16<br><br>While my app is busy with embedded work, <span>ij</span> might connect like this:<br><br><span>  </span>$ <span>java</span> -<span>Dij.user</span>=me -<span>Dij.password</span>=<span>pw</span> -<span>Dij.protocol</span>=jdbc:derby:net://localhost:1527/ <span>org.apache.derby.tools.ij</span><br><span>     </span><span><span >ij</span></span>&gt; connect '<span>NSSimpleDB:retrieveMessagesFromServerOnGetMessage</span>=true;';<br>Watch that punctuation. Put a ':' before the <span>jcc</span><br><span >attributes</span> and a ';' after each one (even the last).<br><br><br>Clients can continue to connect:<br>Press [Enter] to stop Server</tt>
-
-<p>Running this program will also create new directories and files:</p>
-
-<ul>
- <li><span>NSSimpleDB</span><br>
-This directory makes up the <span>NSSimpleDB</span> database.
-</li>
-<li><tt>derby.log</tt><br>
-This log file contains Derby progress and error messages.
-</li></ul>
-
-
-<h2>Example of a Client connecting to the Network Server</h2>
-
-<h3>SimpleNetworkClientSample program</h3>
-
-<p>This program:</p>
-
-<ul>
- <li>loads the DB2 JDBC Universal Driver</li>
- <li>obtains a client connection using the Driver Manager</li>
- <li>obtains a client connection using a DataSource</li>
- <li>tests the database connections by executing a sample query</li>
- <li>closes the connections and then exits the program.</li>
-</ul>
-
-<p>The following files should be installed in the <span class=italic>%DERBY_INSTALL%</span><tt>\demo\programs\nserverdemo\</tt> directory in order to run this sample program:</p>
-<ul>
- <li>Source file: <br><tt>SimpleNetworkClientSample.java</tt></li>
- <li>Compiled class file: <br><tt>SimpleNetworkClientSample.class</tt></li>
-</ul>
-
-<h2>How to run the SimpleNetworkClientSample program</h2>
-
-<p>To connect to the Network Server that has been started as part of the SimpleNetworkServerSample program:</p>
-
-<ol>
- <li>Open a command prompt and change directories to the <span class=italic>%DERBY_INSTALL%</span><tt>\demo\programs\nserverdemo</tt> directory, where <span class=italic>%DERBY_INSTALL%</span> is the directory where you installed Derby.</li>
- <li>Clients of Derby Network Server only need the following jar files in the CLASSPATH in order to connect to the Network Server.<span>  </span>Set the CLASSPATH to include the following jar files:
- <ul>
-  <li>the current directory (".")</li>
-  <li><tt>db2jcc.jar</tt><br>This jar file must be in your CLASSPATH to use the DB2 JDBC Universal Driver.</li>
-  <li><tt>db2jcc_license_c.jar</tt><br>This jar file is the license file for the Universal Driver for Derby.</li>
- </ul></li>
-<li>Once you have set up your environment correctly, execute the
-application from the <br><span class=italic>%DERBY_INSTALL%</span><tt>\demo\programs\nserverdemo\</tt> directory:
-<pre><tt>java SimpleNetworkClientSample</tt></pre>
-</li>
-</ol>
-
-<p>You should receive output similar to the following if the program runs
-successfully:</p>
-
-<tt>Starting Sample client program<br><span>Got a client connection via the <span>DriverManager</span>.</span><br><span>connection</span> from <span>datasource</span>; <span>getDriverName</span> = IBM DB2 JDBC Universal Driver Architecture<br><span>Got a client connection via a <span>DataSource</span>.</span><br>Testing the connection obtained via <span>DriverManager</span> by executing a sample query<br><span>number</span> of rows in <span>sys.systables</span> = 16<br>Testing the connection obtained via a <span>DataSource</span> by executing a sample query<br><span>number</span> of rows in <span>sys.systables</span> = 16<br>Goodbye!</tt>
-
-</body>
-
-</html>
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+
+<head>
+<META http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+<title>Derby Network Server Simple sample program</title>
+</head>
+
+<body>
+
+<h2>Simple Derby Network Server Example</h2>
+
+<h2>Overview</h2>
+
+<p>The primary purpose of this example is to demonstrate how to obtain an embedded
+connection and client connections using the Network Server to the same
+database. This program shows how to use either the DriverManager or a
+DataSource to obtain client connections. </p>
+
+<p>In order for a database to be consistent, only one JVM is allowed to access
+it at a time. The embedded driver is loaded when the Network Server is started.
+Hence, the JVM that starts the Network Server can get an embedded connection to
+the same database that Network Server is accessing to serve the clients from
+other JVMs. This solution allows you to take advantage of the performance
+benefits of the embedded driver as well as allow for client connections from other
+JVMs to connect to the same database.</p>
+
+<p>In this example, the following two programs show how to setup the server and
+client programs when interacting with the Network Server.</p>
+
+<p>SimpleNetworkServerSample.java:
+This program starts the Derby Network Server as well as the embedded
+driver and waits for clients to connect.</p>
+
+<p>SimpleNetworkClientSample.java:
+This is the client program that interacts with the Derby Network Server
+from another JVM.</p>
+
+<h3>SimpleNetworkServerSample program</h3>
+
+<p>In particular, this program:</p>
+
+<ul>
+ <li>starts the Derby Network Server using a property and also loads the embedded driver</li>
+ <li>checks if the Derby Network Server is up and running</li>
+ <li>creates the database 'NSSimpleDB' if not already created </li>
+ <li>obtains an embedded database connection</li>
+ <li>tests the database connection by executing a sample query</li>
+ <li>allows for client connections to connect to the server until the user decides to stop the server and exit the program</li>
+ <li>closes the connection</li>
+ <li>shuts down the Derby
+     Network Server before exiting the program.</li>
+</ul>
+
+<p>The following files should be installed in the <font style=italic>%DERBY_INSTALL%</font><tt><span>\demo\programs\nserverdemo\</span></tt> directory in
+order to run this sample program:</p>
+
+<ul>
+ <li> Source file:</li>
+ <ul>
+  <li><tt>SimpleNetworkServerSample.java</tt></li>
+ </ul>
+ <li>Compiled class file:</li>
+ <ul>
+  <li><tt>SimpleNetworkServerSample.class</tt></li>
+ </ul>
+</ul>
+
+<h2>How to run the SimpleNetworkServerSample program</h2>
+
+<p>To run this simple Derby Network Server sample program:</p>
+
+<ol>
+ <li>Open a command prompt and change directories to the <span class=italic>%DERBY_INSTALL%</span>\demo\programs\nserverdemo
+     directory, where <span class=italic>%DERBY_INSTALL%</span> is the directory
+     where you installed Derby.</li>
+ <li>Set the CLASSPATH to include the following jar files in order to run this
+     program.</li>
+<ul><li>the current directory (".")</li>
+<li><tt>derbynet.jar</tt>: <BR>The Network Server jar file. It must be in your CLASSPATH since we start the Network Server in this program.</li>
+<li><tt>derby.jar</tt>: <BR>The Derby database engine jar file.</li>
+</ul>
+
+<li>Test the CLASSPATH settings by running the following java command:
+
+<pre>java org.apache.derby.tools.sysinfo</pre>
+
+<p>This command will show the Derby jar files that are in the CLASSPATH. </p></li>
+
+<li>Once you have set up your environment correctly, execute the application from the <br><span class=italic>%DERBY_INSTALL%</span>\demo\programs\nserverdemo directory:
+
+<pre>java SimpleNetworkServerSample</pre>
+</li></ol>
+<p>You should receive output similar to the following if the program runs successfully:</p>
+<tt>Starting Network Server<br>Testing if Network Server is up and running!<br>Derby Network Server now running<br><span>Got an embedded connection.</span><br>Testing embedded connection by executing a sample query<br><span>number</span> of rows in <span>sys.systables</span> = 16<br><br>While my app is busy with embedded work, <span>ij</span> might connect like this:<br><br><span>  </span>$ <span>java</span> -<span>Dij.user</span>=me -<span>Dij.password</span>=<span>pw</span> -<span>Dij.protocol</span>=jdbc:derby:net://localhost:1527/ <span>org.apache.derby.tools.ij</span><br><span>     </span><span><span >ij</span></span>&gt; connect '<span>NSSimpleDB:retrieveMessagesFromServerOnGetMessage</span>=true;';<br>Watch that punctuation. Put a ':' before the <span>jcc</span><br><span >attributes</span> and a ';' after each one (even the last).<br><br><br>Clients can continue to connect:<br>Press [Enter] to stop Server</tt>
+
+<p>Running this program will also create new directories and files:</p>
+
+<ul>
+ <li><span>NSSimpleDB</span><br>
+This directory makes up the <span>NSSimpleDB</span> database.
+</li>
+<li><tt>derby.log</tt><br>
+This log file contains Derby progress and error messages.
+</li></ul>
+
+
+<h2>Example of a Client connecting to the Network Server</h2>
+
+<h3>SimpleNetworkClientSample program</h3>
+
+<p>This program:</p>
+
+<ul>
+ <li>loads the DB2 JDBC Universal Driver</li>
+ <li>obtains a client connection using the Driver Manager</li>
+ <li>obtains a client connection using a DataSource</li>
+ <li>tests the database connections by executing a sample query</li>
+ <li>closes the connections and then exits the program.</li>
+</ul>
+
+<p>The following files should be installed in the <span class=italic>%DERBY_INSTALL%</span><tt>\demo\programs\nserverdemo\</tt> directory in order to run this sample program:</p>
+<ul>
+ <li>Source file: <br><tt>SimpleNetworkClientSample.java</tt></li>
+ <li>Compiled class file: <br><tt>SimpleNetworkClientSample.class</tt></li>
+</ul>
+
+<h2>How to run the SimpleNetworkClientSample program</h2>
+
+<p>To connect to the Network Server that has been started as part of the SimpleNetworkServerSample program:</p>
+
+<ol>
+ <li>Open a command prompt and change directories to the <span class=italic>%DERBY_INSTALL%</span><tt>\demo\programs\nserverdemo</tt> directory, where <span class=italic>%DERBY_INSTALL%</span> is the directory where you installed Derby.</li>
+ <li>Clients of Derby Network Server only need the following jar files in the CLASSPATH in order to connect to the Network Server.<span>  </span>Set the CLASSPATH to include the following jar files:
+ <ul>
+  <li>the current directory (".")</li>
+  <li><tt>db2jcc.jar</tt><br>This jar file must be in your CLASSPATH to use the DB2 JDBC Universal Driver.</li>
+  <li><tt>db2jcc_license_c.jar</tt><br>This jar file is the license file for the Universal Driver for Derby.</li>
+ </ul></li>
+<li>Once you have set up your environment correctly, execute the
+application from the <br><span class=italic>%DERBY_INSTALL%</span><tt>\demo\programs\nserverdemo\</tt> directory:
+<pre><tt>java SimpleNetworkClientSample</tt></pre>
+</li>
+</ol>
+
+<p>You should receive output similar to the following if the program runs
+successfully:</p>
+
+<tt>Starting Sample client program<br><span>Got a client connection via the <span>DriverManager</span>.</span><br><span>connection</span> from <span>datasource</span>; <span>getDriverName</span> = IBM DB2 JDBC Universal Driver Architecture<br><span>Got a client connection via a <span>DataSource</span>.</span><br>Testing the connection obtained via <span>DriverManager</span> by executing a sample query<br><span>number</span> of rows in <span>sys.systables</span> = 16<br>Testing the connection obtained via a <span>DataSource</span> by executing a sample query<br><span>number</span> of rows in <span>sys.systables</span> = 16<br>Goodbye!</tt>
+
+</body>
+
+</html>

Propchange: incubator/derby/code/trunk/java/demo/nserverdemo/simpleserversample.html
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/derby/code/trunk/java/demo/readme.html
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/demo/readme.html?rev=164630&r1=164629&r2=164630&view=diff
==============================================================================
--- incubator/derby/code/trunk/java/demo/readme.html (original)
+++ incubator/derby/code/trunk/java/demo/readme.html Mon Apr 25 12:29:37 2005
@@ -1,15 +1,15 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
-
-<html>
-<head><META http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
-</head>
-<frameset cols="170, *">
-    <frame src="navbar.html" name="navbar" scrolling="Auto" noresize>	   
-    <frame src="demo.html" name="mainPage" scrolling="Auto">
-</frameset>
-<body>
-
-
-
-</body>
-</html>
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+
+<html>
+<head><META http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+</head>
+<frameset cols="170, *">
+    <frame src="navbar.html" name="navbar" scrolling="Auto" noresize>	   
+    <frame src="demo.html" name="mainPage" scrolling="Auto">
+</frameset>
+<body>
+
+
+
+</body>
+</html>

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

Modified: incubator/derby/code/trunk/java/demo/simple/SimpleApp.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/demo/simple/SimpleApp.java?rev=164630&r1=164629&r2=164630&view=diff
==============================================================================
--- incubator/derby/code/trunk/java/demo/simple/SimpleApp.java (original)
+++ incubator/derby/code/trunk/java/demo/simple/SimpleApp.java Mon Apr 25 12:29:37 2005
@@ -1,244 +1,244 @@
-/*
-
-   Derby - Class SimpleApp
-
-   Copyright 2001, 2004 The Apache Software Foundation or its licensors, as applicable.
-
-   Licensed 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.DriverManager;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Statement;
-
-import java.util.Properties;
-
-
-/**
- * This sample program is a minimal JDBC application showing
- * JDBC access to Derby.
- *
- * Instructions for how to run this program are
- * given in <A HREF=example.html>example.html</A>.
- *
- * 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)
- *    * jccjdbcclient (if Derby is running embedded in the JCC Server framework)
- *
- * @author janet
- */
-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:";
-
-    public static void main(String[] args)
-    {
-        new SimpleApp().go(args);
-    }
-
-    void go(String[] args)
-    {
-        /* parse the arguments to determine which framework is desired*/
-        parseArguments(args);
-
-        System.out.println("SimpleApp starting in " + framework + " mode.");
-
-        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();
-            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.
-             */
-            conn = DriverManager.getConnection(protocol +
-                    "derbyDB;create=true", props);
-
-            System.out.println("Connected to and created database derbyDB");
-
-            conn.setAutoCommit(false);
-
-            /*
-               Creating a statement lets us issue commands against
-               the connection.
-             */
-            Statement s = conn.createStatement();
-
-            /*
-               We create a table, add a few rows, and update one.
-             */
-            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.')");
-            System.out.println("Inserted 1956 Webster");
-            s.execute("insert into derbyDB values (1910,'Union St.')");
-            System.out.println("Inserted 1910 Union");
-            s.execute(
-                "update derbyDB set num=180, addr='Grand Ave.' where num=1956");
-            System.out.println("Updated 1956 Webster to 180 Grand");
-
-            s.execute(
-                "update derbyDB set num=300, addr='Lakeshore Ave.' where num=180");
-            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");
-
-            if (!rs.next())
-            {
-                throw new Exception("Wrong number of rows");
-            }
-
-            if (rs.getInt(1) != 300)
-            {
-                throw new Exception("Wrong row returned");
-            }
-
-            if (!rs.next())
-            {
-                throw new Exception("Wrong number of rows");
-            }
-
-            if (rs.getInt(1) != 1910)
-            {
-                throw new Exception("Wrong row returned");
-            }
-
-            if (rs.next())
-            {
-                throw new Exception("Wrong number of rows");
-            }
-
-            System.out.println("Verified the rows");
-
-            s.execute("drop table derbyDB");
-            System.out.println("Dropped table derbyDB");
-
-            /*
-               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.
-             */
-            conn.commit();
-            conn.close();
-            System.out.println("Committed transaction and closed connection");
-
-            /*
-               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".
-             */
-            boolean gotSQLExc = false;
-
-            if (framework.equals("embedded"))
-            {
-                try
-                {
-                    DriverManager.getConnection("jdbc:derby:;shutdown=true");
-                }
-                catch (SQLException se)
-                {
-                    gotSQLExc = true;
-                }
-
-                if (!gotSQLExc)
-                {
-                    System.out.println("Database did not shut down normally");
-                }
-                else
-                {
-                    System.out.println("Database shut down normally");
-                }
-            }
-        }
-        catch (Throwable e)
-        {
-            System.out.println("exception thrown:");
-
-            if (e instanceof SQLException)
-            {
-                printSQLError((SQLException) e);
-            }
-            else
-            {
-                e.printStackTrace();
-            }
-        }
-
-        System.out.println("SimpleApp finished");
-    }
-
-    static void printSQLError(SQLException e)
-    {
-        while (e != null)
-        {
-            System.out.println(e.toString());
-            e = e.getNextException();
-        }
-    }
-
-    private void parseArguments(String[] args)
-    {
-        int length = args.length;
-
-        for (int index = 0; index < length; index++)
-        {
-            if (args[index].equalsIgnoreCase("jccjdbcclient"))
-            {
-                framework = "jccjdbc";
-                driver = "com.ibm.db2.jcc.DB2Driver";
-                protocol = "jdbc:derby:net://localhost:1527/";
-            }
-        }
-    }
-}
+/*
+
+   Derby - Class SimpleApp
+
+   Copyright 2001, 2004 The Apache Software Foundation or its licensors, as applicable.
+
+   Licensed 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.DriverManager;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+
+import java.util.Properties;
+
+
+/**
+ * This sample program is a minimal JDBC application showing
+ * JDBC access to Derby.
+ *
+ * Instructions for how to run this program are
+ * given in <A HREF=example.html>example.html</A>.
+ *
+ * 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)
+ *    * jccjdbcclient (if Derby is running embedded in the JCC Server framework)
+ *
+ * @author janet
+ */
+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:";
+
+    public static void main(String[] args)
+    {
+        new SimpleApp().go(args);
+    }
+
+    void go(String[] args)
+    {
+        /* parse the arguments to determine which framework is desired*/
+        parseArguments(args);
+
+        System.out.println("SimpleApp starting in " + framework + " mode.");
+
+        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();
+            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.
+             */
+            conn = DriverManager.getConnection(protocol +
+                    "derbyDB;create=true", props);
+
+            System.out.println("Connected to and created database derbyDB");
+
+            conn.setAutoCommit(false);
+
+            /*
+               Creating a statement lets us issue commands against
+               the connection.
+             */
+            Statement s = conn.createStatement();
+
+            /*
+               We create a table, add a few rows, and update one.
+             */
+            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.')");
+            System.out.println("Inserted 1956 Webster");
+            s.execute("insert into derbyDB values (1910,'Union St.')");
+            System.out.println("Inserted 1910 Union");
+            s.execute(
+                "update derbyDB set num=180, addr='Grand Ave.' where num=1956");
+            System.out.println("Updated 1956 Webster to 180 Grand");
+
+            s.execute(
+                "update derbyDB set num=300, addr='Lakeshore Ave.' where num=180");
+            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");
+
+            if (!rs.next())
+            {
+                throw new Exception("Wrong number of rows");
+            }
+
+            if (rs.getInt(1) != 300)
+            {
+                throw new Exception("Wrong row returned");
+            }
+
+            if (!rs.next())
+            {
+                throw new Exception("Wrong number of rows");
+            }
+
+            if (rs.getInt(1) != 1910)
+            {
+                throw new Exception("Wrong row returned");
+            }
+
+            if (rs.next())
+            {
+                throw new Exception("Wrong number of rows");
+            }
+
+            System.out.println("Verified the rows");
+
+            s.execute("drop table derbyDB");
+            System.out.println("Dropped table derbyDB");
+
+            /*
+               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.
+             */
+            conn.commit();
+            conn.close();
+            System.out.println("Committed transaction and closed connection");
+
+            /*
+               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".
+             */
+            boolean gotSQLExc = false;
+
+            if (framework.equals("embedded"))
+            {
+                try
+                {
+                    DriverManager.getConnection("jdbc:derby:;shutdown=true");
+                }
+                catch (SQLException se)
+                {
+                    gotSQLExc = true;
+                }
+
+                if (!gotSQLExc)
+                {
+                    System.out.println("Database did not shut down normally");
+                }
+                else
+                {
+                    System.out.println("Database shut down normally");
+                }
+            }
+        }
+        catch (Throwable e)
+        {
+            System.out.println("exception thrown:");
+
+            if (e instanceof SQLException)
+            {
+                printSQLError((SQLException) e);
+            }
+            else
+            {
+                e.printStackTrace();
+            }
+        }
+
+        System.out.println("SimpleApp finished");
+    }
+
+    static void printSQLError(SQLException e)
+    {
+        while (e != null)
+        {
+            System.out.println(e.toString());
+            e = e.getNextException();
+        }
+    }
+
+    private void parseArguments(String[] args)
+    {
+        int length = args.length;
+
+        for (int index = 0; index < length; index++)
+        {
+            if (args[index].equalsIgnoreCase("jccjdbcclient"))
+            {
+                framework = "jccjdbc";
+                driver = "com.ibm.db2.jcc.DB2Driver";
+                protocol = "jdbc:derby:net://localhost:1527/";
+            }
+        }
+    }
+}

Propchange: incubator/derby/code/trunk/java/demo/simple/SimpleApp.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/derby/code/trunk/java/demo/simple/derby.properties
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/demo/simple/derby.properties?rev=164630&r1=164629&r2=164630&view=diff
==============================================================================
--- incubator/derby/code/trunk/java/demo/simple/derby.properties (original)
+++ incubator/derby/code/trunk/java/demo/simple/derby.properties Mon Apr 25 12:29:37 2005
@@ -1,4 +1,4 @@
-# derby.properties
-#
-# we are using the default properties values for this demo
-#
+# derby.properties
+#
+# we are using the default properties values for this demo
+#

Propchange: incubator/derby/code/trunk/java/demo/simple/derby.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/derby/code/trunk/java/demo/simple/example.html
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/demo/simple/example.html?rev=164630&r1=164629&r2=164630&view=diff
==============================================================================
--- incubator/derby/code/trunk/java/demo/simple/example.html (original)
+++ incubator/derby/code/trunk/java/demo/simple/example.html Mon Apr 25 12:29:37 2005
@@ -1,259 +1,259 @@
-<!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="GENERATOR" content="Quadralay WebWorks Publisher 5.0.4">
-<meta name="TEMPLATEBASE" content="Dynamic HTML">
-<meta name="LASTUPDATED" content="06/25/02 12:10:42">
-<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
-</h1>
- 
-
-<ul class="ChapterTOC">  <li class="ChapterTOC"><a name="820053"> </a>  <a href="#820067">Overview</a>
-  <li class="ChapterTOC"><a name="820061"> </a>  <a href="#816689">What's Included?</a>
-  <li class="ChapterTOC"><a name="820065"> </a>  <a href="#816722">How to Run This Sample Application in an Embedded Environment</a>
-</ul>
-<h2 class="Heading2"><a name="820067"> </a>Overview
-</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 accomplishes the following tasks:
-</p><ul class="Normal">  <li class="Normal"><a name="817266"> </a>starts up the  Derby engine, if necessary
-  <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 necessary
-</ul>
-<p class="Body">
-  <a name="817267"> </a>The application runs in an embedded environment. This is the simplest Derby environment. The application starts up an instance of Derby within the current JVM and shuts down the instance before it completes. No network access is involved. In an embedded environment, only one application at a time can access a database.
-</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, does 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>
-  <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>
-</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 log 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>
-</ul>
-<h2 class="Heading2"><a name="816722"> </a>How to Run This Sample Application in an Embedded Environment
-</h2>
- <ol type="1">  <li class="Normal" value="1"><a name="816724"> </a>Open a command window and change directories to the <em class="fileName">/demo/programs/simple</em> directory.
-  <li class="Normal" value="2"><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" value="3"><a name="819207"> </a>In the command window, set CLASSPATH as follows:<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>
-  </tr>
-  <tr valign="top">
-    <td class="DefaultTable"><a name="821049"> </a><p class="CellBody">main Derby library for the product:</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</p>
-</td>
-    <td class="DefaultTable"><a name="819206"> </a><p class="CellBody">.</p>
-</td>
-  </tr>
-</table>
-
-
-</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 Class Path for an Embedded Environment
-</h3>
-<a name="819214"> </a><p class="CellBody">Derby provides a script to help you get started setting class path 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 class path. </p>
-</td>
-  </tr>
-</table>
-</p>
-
-</p>
-  <li class="Normal" value="4"><a name="819222"> </a>Run Derby's utility for testing the class path 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 CLASS PATH:</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 class path.</p>
-
- 
-
-<p class="BodyRelative">
-  <a name="820878"> </a>If something is missing from your class path environment, the utility indicates what is missing. For example, if you neglected to add the directory containing the SimpleApp class to your class path, 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 CLASS PATH:</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 CLASS PATH:</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" value="5"><a name="818903"> </a>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"><a name="816737">java SimpleApp</a></p></ol>
-<p class="Body">
-  <a name="818687"> </a>A successful run produces the following output: 
-</p><p class="Output"><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
-<br>
-</p>
-
-<p class="NavBarVersion">Apache Derby Version 10</p>
-
-</body>
-</html>
+<!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="GENERATOR" content="Quadralay WebWorks Publisher 5.0.4">
+<meta name="TEMPLATEBASE" content="Dynamic HTML">
+<meta name="LASTUPDATED" content="06/25/02 12:10:42">
+<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
+</h1>
+ 
+
+<ul class="ChapterTOC">  <li class="ChapterTOC"><a name="820053"> </a>  <a href="#820067">Overview</a>
+  <li class="ChapterTOC"><a name="820061"> </a>  <a href="#816689">What's Included?</a>
+  <li class="ChapterTOC"><a name="820065"> </a>  <a href="#816722">How to Run This Sample Application in an Embedded Environment</a>
+</ul>
+<h2 class="Heading2"><a name="820067"> </a>Overview
+</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 accomplishes the following tasks:
+</p><ul class="Normal">  <li class="Normal"><a name="817266"> </a>starts up the  Derby engine, if necessary
+  <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 necessary
+</ul>
+<p class="Body">
+  <a name="817267"> </a>The application runs in an embedded environment. This is the simplest Derby environment. The application starts up an instance of Derby within the current JVM and shuts down the instance before it completes. No network access is involved. In an embedded environment, only one application at a time can access a database.
+</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, does 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>
+  <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>
+</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 log 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>
+</ul>
+<h2 class="Heading2"><a name="816722"> </a>How to Run This Sample Application in an Embedded Environment
+</h2>
+ <ol type="1">  <li class="Normal" value="1"><a name="816724"> </a>Open a command window and change directories to the <em class="fileName">/demo/programs/simple</em> directory.
+  <li class="Normal" value="2"><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" value="3"><a name="819207"> </a>In the command window, set CLASSPATH as follows:<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>
+  </tr>
+  <tr valign="top">
+    <td class="DefaultTable"><a name="821049"> </a><p class="CellBody">main Derby library for the product:</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</p>
+</td>
+    <td class="DefaultTable"><a name="819206"> </a><p class="CellBody">.</p>
+</td>
+  </tr>
+</table>
+
+
+</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 Class Path for an Embedded Environment
+</h3>
+<a name="819214"> </a><p class="CellBody">Derby provides a script to help you get started setting class path 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 class path. </p>
+</td>
+  </tr>
+</table>
+</p>
+
+</p>
+  <li class="Normal" value="4"><a name="819222"> </a>Run Derby's utility for testing the class path 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 CLASS PATH:</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 class path.</p>
+
+ 
+
+<p class="BodyRelative">
+  <a name="820878"> </a>If something is missing from your class path environment, the utility indicates what is missing. For example, if you neglected to add the directory containing the SimpleApp class to your class path, 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 CLASS PATH:</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 CLASS PATH:</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" value="5"><a name="818903"> </a>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"><a name="816737">java SimpleApp</a></p></ol>
+<p class="Body">
+  <a name="818687"> </a>A successful run produces the following output: 
+</p><p class="Output"><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
+<br>
+</p>
+
+<p class="NavBarVersion">Apache Derby Version 10</p>
+
+</body>
+</html>

Propchange: incubator/derby/code/trunk/java/demo/simple/example.html
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message