db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fuzzylo...@apache.org
Subject svn commit: r190803 - in /incubator/derby/code/trunk/java/demo: nserverdemo/NsSample.java nserverdemo/SimpleNetworkClientSample.java nserverdemo/SimpleNetworkServerSample.java nserverdemo/nserverdemo.html nserverdemo/simpleserversample.html simple/SimpleApp.java
Date Wed, 15 Jun 2005 20:49:32 GMT
Author: fuzzylogic
Date: Wed Jun 15 13:49:32 2005
New Revision: 190803

URL: http://svn.apache.org/viewcvs?rev=190803&view=rev
Log:
DERBY-247: Update demos to support Derby Network Client driver.

Committed for Lance Andersen <Lance.Andersen@sun.com>

Modified:
    incubator/derby/code/trunk/java/demo/nserverdemo/NsSample.java
    incubator/derby/code/trunk/java/demo/nserverdemo/SimpleNetworkClientSample.java
    incubator/derby/code/trunk/java/demo/nserverdemo/SimpleNetworkServerSample.java
    incubator/derby/code/trunk/java/demo/nserverdemo/nserverdemo.html
    incubator/derby/code/trunk/java/demo/nserverdemo/simpleserversample.html
    incubator/derby/code/trunk/java/demo/simple/SimpleApp.java

Modified: incubator/derby/code/trunk/java/demo/nserverdemo/NsSample.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/demo/nserverdemo/NsSample.java?rev=190803&r1=190802&r2=190803&view=diff
==============================================================================
--- incubator/derby/code/trunk/java/demo/nserverdemo/NsSample.java (original)
+++ incubator/derby/code/trunk/java/demo/nserverdemo/NsSample.java Wed Jun 15 13:49:32 2005
@@ -40,7 +40,8 @@
  The program:
 
  1.	starts the Derby Network Server
- 2.	loads the IBM DB2 JDBC Universal driver
+ 2.	loads the IBM DB2 JDBC Universal driver or derby client JDBC driver
+        (default is the derby client JDBC driver)
  3. creates the database if not already created
  4. checks to see if the schema is already created, and if not,
  5. creates the schema which includes the table SAMPLETBL and corresponding indexes.
@@ -65,6 +66,7 @@
 public class NsSample {
 
 	public static final String DB2_JDBC_UNIVERSAL_DRIVER = new String("com.ibm.db2.jcc.DB2Driver");
+        public static final String DERBY_CLIENT_DRIVER = "org.apache.derby.jdbc.ClientDriver";
 	public static int NUM_ROWS = 50; /* Number of rows to load initially */
 	public static int ITERATIONS = 10;  //Each client does these many iterations
 	public static int NUM_CLIENT_THREADS = 2;
@@ -80,19 +82,33 @@
 	// This URL describes the target database for type 4 connectivity
 	// Notice that the properties may be established via the URL syntax
 	private static final String CS_NS_DBURL= "jdbc:derby:net://localhost:"+NETWORKSERVER_PORT+"/NSSampledb;create=true;retrieveMessagesFromServerOnGetMessage=true;deferPrepares=true;";
+        // URL for the Derby client JDBC driver.
+	private static final String DERBY_CLIENT_URL= "jdbc:derby://localhost:"+NETWORKSERVER_PORT+"/NSSampledb;create=true;";
+
+        // Default to using the Derby Client JDBC Driver for database connections
+        String url = DERBY_CLIENT_URL;
+        String jdbcDriver = DERBY_CLIENT_DRIVER;
 
 	public static void main(String[] args) throws Exception {
 
+                   new nserverdemo.NsSample().startSample(args);
+        }
+	public void startSample(String[] args) throws Exception {
 	  NetworkServerUtil nwServer;
 
-	  // DB2Connection provides additional functionality than java.sql.Connection
-	  // One can use either depending on the requirements
 	  Connection conn = null;
 
 	  PrintWriter pw = null;
+          
+      
 
 	  try  {
+
+                // Determine which JDBC driver we are using with Derby
+                parseArguments(args);
+
 		pw = new PrintWriter(System.out,true);	// to print messages
+		pw.println("Using JDBC driver: " + jdbcDriver);
 
 		/* Start - In order to start the network server do the following
 		   In case you want to start the server as a script or another program
@@ -138,11 +154,11 @@
 		pw.println("[NsSample] Sample Derby Network Server program demo starting. ");
 		pw.println("Please wait .....................");
 
-		// Load the JCC Driver
+		// Load the JDBC Driver
 		try	{
-			Class.forName(DB2_JDBC_UNIVERSAL_DRIVER).newInstance();
+			Class.forName(jdbcDriver).newInstance();
 		} catch (Exception e) {
-			pw.println("[NsSample] Unable to load JCC driver. Following exception was thrown");
+			pw.println("[NsSample] Unable to load the JDBC driver. Following exception was thrown");
 			e.printStackTrace();
 			System.exit(1);  //critical error, so exit
 		  }
@@ -156,10 +172,10 @@
 		properties.setProperty("user","cloud");
 		properties.setProperty("password","scape");
 
-		// Get database connection using the JCC client via DriverManager api
+		// Get database connection via DriverManager api
 		try	{
 			
-			conn =  (Connection) DriverManager.getConnection(CS_NS_DBURL, properties);
+			conn =  (Connection) DriverManager.getConnection(url, properties);
 		} catch(Exception e) {
 			pw.println("[NsSample] Connection request unsuccessful, exception thrown was: ");
 			pw.println("[NsSample] Please check if all the jar files are in the classpath and the
dbUrl is set correctly.");
@@ -191,7 +207,7 @@
 		   Please be aware of the database URL for obtaining a client connection
 		 */
 		for (int i=1; i<NUM_CLIENT_THREADS; i++) {
-			clientThreads[i] = new NsSampleClientThread(i+1,CS_NS_DBURL,properties,pw);
+			clientThreads[i] = new NsSampleClientThread(i+1,url,properties,pw);
 			clientThreads[i].start();
 
 		}
@@ -213,4 +229,34 @@
 		if(pw != null) pw.close();
       }
 	 }
+
+    /**
+     * Determine which jdbc driver to use by parsing the command line args.
+     *  Accepted values:
+     *  jccjdbclient   - The DB2 type 4 universal driver
+     *  derbyclient    - The Derby network driver (default).
+     *  Note: because this is just a sample, we only care about whether
+     *  the above values are specified.  If they are not, then we default
+     *  to the Derby network driver.
+     */
+    private void parseArguments(String[] args)
+    {
+        int length = args.length;
+
+        for (int index = 0; index < length; index++)
+        {
+            if (args[index].equalsIgnoreCase("jccjdbcclient"))
+            {
+                jdbcDriver = DB2_JDBC_UNIVERSAL_DRIVER;
+                url = CS_NS_DBURL;
+                break;
+            } else if (args[index].equalsIgnoreCase("derbyClient"))
+            {
+                jdbcDriver = DERBY_CLIENT_DRIVER;
+                url = DERBY_CLIENT_URL;
+                break;
+            }
+        }
+    }
+
 }

Modified: incubator/derby/code/trunk/java/demo/nserverdemo/SimpleNetworkClientSample.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/demo/nserverdemo/SimpleNetworkClientSample.java?rev=190803&r1=190802&r2=190803&view=diff
==============================================================================
--- incubator/derby/code/trunk/java/demo/nserverdemo/SimpleNetworkClientSample.java (original)
+++ incubator/derby/code/trunk/java/demo/nserverdemo/SimpleNetworkClientSample.java Wed Jun
15 13:49:32 2005
@@ -31,7 +31,8 @@
  * and interact with Derby Network Server
  *
  * In particular,this sample program
- * 1)   loads the DB2 Universal JDBC Driver
+ * 1)   loads the DB2 Universal JDBC Driver or the Derby Network Client driver
+   (default is the derby network client driver)
  * 2)	obtains a client connection using the Driver Manager
  * 3)	obtains a client connection using a DataSource
  * 4)	tests the database connections by executing a sample query
@@ -62,17 +63,35 @@
 	 */
 	private static final String DB2_JDBC_UNIVERSAL_DRIVER = "com.ibm.db2.jcc.DB2Driver";
 	private static final String DB2_JCC_DS = "com.ibm.db2.jcc.DB2SimpleDataSource";
+	/**
+	 * Derby Network Client Driver class names
+	 */
+
+public static final String DERBY_CLIENT_DRIVER = "org.apache.derby.jdbc.ClientDriver";
+	private static final String DERBY_CLIENT_DS = "org.apache.derby.jdbc.ClientDataSource";
 
 	/**
 	 * This URL is used to connect to Derby Network Server using the DriverManager.
-	 * Also, this url describes the target database for type 4 connectivity
+	 * This URL is for the DB2 JDBC Universal Driver
 	 * Notice that the properties may be established via the URL syntax
 	 */
 	private static final String CS_NS_DBURL= "jdbc:derby:net://localhost:"+NETWORKSERVER_PORT+"/"+DBNAME+";retrieveMessagesFromServerOnGetMessage=true;deferPrepares=true;";
 
+        // URL for the Derby client JDBC driver.
+        private static final String DERBY_CLIENT_URL= "jdbc:derby://localhost:"+ NETWORKSERVER_PORT+"/NSSampledb;create=true";
 
-	public static void main (String[] args)
-		throws Exception
+        // Default to using the Derby Client JDBC Driver for database connections
+        String url = DERBY_CLIENT_URL;
+        String jdbcDriver = DERBY_CLIENT_DRIVER;
+        String jdbcDataSource = DERBY_CLIENT_DS;
+
+	public static void main (String[] args) throws Exception
+        {
+
+                   new SimpleNetworkClientSample().startSample(args);
+
+        }
+	public void startSample (String[] args) throws Exception
 	{
 		DataSource clientDataSource = null;
 		Connection clientConn1 = null;
@@ -82,10 +101,11 @@
 		try
 		{
 			System.out.println("Starting Sample client program ");
+                        // Determine which JDBC driver to use
+                        parseArguments(args);
 
-			// load DB2 JDBC UNIVERSAL DRIVER to enable client connections to
-			// Derby Network Server
-			loadJCCDriver();
+			// load  the appropriate JDBC Driver
+			loadDriver();
 
 			// get a client connection using DriverManager
 			clientConn1 = getClientDriverManagerConnection();
@@ -128,7 +148,7 @@
 	 * @return	returns database connection
 	 * @throws Exception if there is any error
 	 */
-	public static Connection getClientDataSourceConn(javax.sql.DataSource ds)
+	public Connection getClientDataSourceConn(javax.sql.DataSource ds)
 		throws Exception
 	{
 		Connection conn = ds.getConnection("usr2", "pass2");
@@ -147,10 +167,10 @@
 	 * @return	returns DataSource
 	 * @throws Exception if there is any error
 	 */
-	public static javax.sql.DataSource getClientDataSource(String database, String user, String
+	public javax.sql.DataSource getClientDataSource(String database, String user, String
 									  password) throws SQLException, ClassNotFoundException, InstantiationException,
IllegalAccessException, NoSuchMethodException, InvocationTargetException
 	{
-		Class nsDataSource = Class.forName(DB2_JCC_DS);
+		Class nsDataSource = Class.forName(jdbcDataSource);
 		DataSource ds = (DataSource) nsDataSource.newInstance();
 
 		// can also include Derby URL attributes along with the database name
@@ -180,10 +200,14 @@
 		args = new Object[] {new Integer(1527)};
 		portnumber.invoke(ds, args);
 
-		// driver type must be 4 to access Derby Network Server
-		Method drivertype = nsDataSource.getMethod("setDriverType", methodParams);
-		args = new Object[] {new Integer(4)};
-		drivertype.invoke(ds, args);
+                // The following is only applicable to the DB2 JDBC driver
+                if(jdbcDataSource.equals( DB2_JCC_DS))
+                {
+			// driver type must be 4 to access Derby Network Server
+			Method drivertype = nsDataSource.getMethod("setDriverType", methodParams);
+			args = new Object[] {new Integer(4)};
+			drivertype.invoke(ds, args);
+                }
 
 		return ds;
 
@@ -191,21 +215,21 @@
 
 
 	/**
-	 * Load DB2 JDBC UNIVERSAL DRIVER
+	 * Load the appropriate JDBC driver
 	 */
-	public static void loadJCCDriver()
+	public void loadDriver()
 		throws Exception
 	{
-		// Load the JCC Driver
-		Class.forName(DB2_JDBC_UNIVERSAL_DRIVER).newInstance();
+		// Load the  Driver
+		Class.forName(jdbcDriver).newInstance();
 	}
 
 	/**
 	 * Get a client connection using the DriverManager
-	 * @pre DB2 JDBC Universal driver must have been loaded before calling this method
+	 * @pre The JDBC driver must have been loaded before calling this method
 	 * @return Connection	client database connection
 	 */
-	public static Connection getClientDriverManagerConnection()
+	public Connection getClientDriverManagerConnection()
 		throws Exception
 	{
 
@@ -217,8 +241,8 @@
 		properties.setProperty("user","cloud");
 		properties.setProperty("password","scape");
 
-		// Get database connection using the JCC client via DriverManager api
-		Connection conn = DriverManager.getConnection(CS_NS_DBURL,properties); 
+		// Get database connection  via DriverManager api
+		Connection conn = DriverManager.getConnection(url,properties); 
 
 		return conn;
 	}
@@ -229,7 +253,7 @@
 	 * @param	conn 	database connection
 	 * @throws Exception if there is any error
 	 */
-	public static void test(Connection conn)
+	public void test(Connection conn)
 		throws Exception
 	{
 
@@ -257,6 +281,38 @@
 		  	stmt.close();
  	  }
 	}
+   /**
+     * Determine which jdbc driver to use by parsing the command line args.
+     *  Accepted values:
+     *  jccjdbclient   - The DB2 type 4 universal driver
+     *  derbyclient    - The Derby network driver (default).
+     *  Note: because this is just a sample, we only care about whether
+     *  the above values are specified.  If they are not, then we default
+     *  to the Derby network driver.
+     */
+    private void parseArguments(String[] args)
+    {
+        int length = args.length;
+
+        for (int index = 0; index < length; index++)
+        {
+            if (args[index].equalsIgnoreCase("jccjdbcclient"))
+            {
+
+                jdbcDriver = DB2_JDBC_UNIVERSAL_DRIVER;
+                jdbcDataSource = DB2_JCC_DS;
+                url = CS_NS_DBURL;
+                break;
+            } else if (args[index].equalsIgnoreCase("derbyClient"))
+            {
+                jdbcDriver = DERBY_CLIENT_DRIVER;
+                jdbcDataSource = DERBY_CLIENT_DS;
+                url = DERBY_CLIENT_URL;
+                break;
+            }
+        }
+    }
+
 }
 
 

Modified: incubator/derby/code/trunk/java/demo/nserverdemo/SimpleNetworkServerSample.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/demo/nserverdemo/SimpleNetworkServerSample.java?rev=190803&r1=190802&r2=190803&view=diff
==============================================================================
--- incubator/derby/code/trunk/java/demo/nserverdemo/SimpleNetworkServerSample.java (original)
+++ incubator/derby/code/trunk/java/demo/nserverdemo/SimpleNetworkServerSample.java Wed Jun
15 13:49:32 2005
@@ -308,10 +308,8 @@
 
 		String ijUsage = "\nWhile my app is busy with embedded work, ";
 		ijUsage += "ij might connect like this:\n\n";
-		ijUsage +=  "\t$ java -Dij.user=me -Dij.password=pw -Dij.protocol=jdbc:derby:net://localhost:1527/
org.apache.derby.tools.ij\n";
-		ijUsage += "\tij> connect '" + DBNAME + ":retrieveMessagesFromServerOnGetMessage=true;';\n";
-		ijUsage += "Watch that punctuation.  Put a ':' before the jcc\n";
-		ijUsage += "attributes and a ';' after each one (even the last).\n\n";
+		ijUsage +=  "\t$ java -Dij.user=me -Dij.password=pw -Dij.protocol=jdbc:derby://localhost:1527/
org.apache.derby.tools.ij\n";
+		ijUsage += "\tij> connect '" + DBNAME + "';\n\n";
 
 		return ijUsage;
 	}

Modified: incubator/derby/code/trunk/java/demo/nserverdemo/nserverdemo.html
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/demo/nserverdemo/nserverdemo.html?rev=190803&r1=190802&r2=190803&view=diff
==============================================================================
--- incubator/derby/code/trunk/java/demo/nserverdemo/nserverdemo.html (original)
+++ incubator/derby/code/trunk/java/demo/nserverdemo/nserverdemo.html Wed Jun 15 13:49:32
2005
@@ -12,7 +12,7 @@
 <UL>
   <LI>starts the Derby Network Server 
   <LI>checks if the Derby Network Server is running 
-  <LI>loads the DB2 JDBC Universal Driver 
+  <LI>loads the DB2 JDBC Universal Driver or the Derby Client Network JDBC Driver
   <LI>creates the database '<tt>NsSampledb</tt>' if not already created

   <LI>checks to see if the schema is already created, and if not, 
   creates the schema which includes the <tt>SAMPLETBL</tt> table and corresponding

@@ -81,10 +81,11 @@
   class=italic>%DERBY_INSTALL%</SPAN><tt>\demo\programs\</tt> directory,
where <SPAN 
   class=italic>%DERBY_INSTALL%</SPAN> is the directory where you installed Derby.

   <LI>Set the CLASSPATH to the current directory (".") and also include the following

-  jar files in order to use the Derby Network Server and the DB2 JDBC Universal Driver.
+  jar files in order to use the Derby Network Server and the DB2 JDBC Universal Driver or
the Derby Client Network JDBC Driver.
 <ul>
 <li><tt>derbynet.jar</tt><br>The Network Server jar file. It must
be in your CLASSPATH to use any of the Derby Network 
 Server functions.</li>
+<li><tt>derbyclient.jar</tt><br>This jar file must be in your CLASSPATH
to use the Derby Client Network JDBC Driver.</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 
@@ -96,54 +97,64 @@
 the DB2 JDBC Universal Driver along with their respective versions.</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\</tt> directory:<br>
-<pre>java nserverdemo.NsSample</pre>
+<pre>java nserverdemo.NsSample [driverType]</pre>
+<ul>
+<li>Where the possible values for driverType are:
+<ul>
+<li>derbyClient (default)
+<li>jccjdbcclient
+</ul>
+</ul>
 </li>
 </OL>
 You should receive output similar to the following if the 
 program runs successfully:<br><br>
 
-<tt>Derby Network Server created<br>
-[NsSample] Unable to obtain a connection to network server, trying again after 3000 ms.<br>
+<tt>
+Using JDBC driver: org.apache.derby.jdbc.ClientDriver<br>
+Derby Network Server created<br>
 Server is ready to accept connections on port 1621.<br>
 Connection number: 1.<br>
 [NsSample] Derby Network Server started.<br>
 [NsSample] Sample Derby Network Server program demo starting. <br>
 Please wait .....................<br>
 Connection number: 2.<br>
-[NsSampleWork] Table 'SAMPLETBL' already exists; no need to create schema again.<br>
+[NsSampleWork] Begin creating table - SAMPLETBL and necessary indexes. <br>
 [NsSampleClientThread] Thread id - 1; started.<br>
 [NsSampleWork] Thread id - 1; requests database connection, dbUrl =jdbc:derby:NSSampledb;<br>
 [NsSampleClientThread] Thread id - 2; started.<br>
-[NsSampleWork] Thread id - 2; requests database connection, dbUrl <br>=jdbc:derby:net://localhost:1621/NSSampledb;create=true:retrieveMessagesFromServerOnGetMessage=true;deferPrepares=true;<br>
+[NsSampleWork] Thread id - 2; requests database connection, dbUrl =jdbc:derby://localhost:1621/NSSampledb;create=true;<br>
 Connection number: 3.<br>
-[NsSampleWork] Thread id - 1 selected 1 row [61,Derby28        ,3.20918E21,9854]<br>
-[NsSampleWork] Thread id - 1; inserted 1 row.<br>
-[NsSampleWork] Thread id - 1; deleted 1 row with t_key = 9854<br>
+[NsSampleWork] Thread id - 1 selected 1 row [998,Derby41        ,2.92903314E14,9572]<br>
+[NsSampleWork] Thread id - 2 selected 1 row [998,Derby41        ,2.92903314E14,9572]<br>
+[NsSampleWork] Thread id - 1 selected 1 row [998,Derby41        ,2.92903314E14,9572]<br>
+[NsSampleWork] Thread id - 1 selected 1 row [998,Derby41        ,2.92903314E14,9572]<br>
+[NsSampleWork] Thread id - 1 selected 1 row [998,Derby41        ,2.92903314E14,9572]<br>
 [NsSampleWork] Thread id - 1; inserted 1 row.<br>
-[NsSampleWork] Thread id - 1; deleted 1 row with t_key = 9818<br>
-[NsSampleWork] Thread id - 2; deleted 0 row with t_key = 9854<br>
-[NsSampleWork] Thread id - 1; updated 1 row with t_key = 9481<br>
-[NsSampleWork] Thread id - 1; updated 1 row with t_key = 9481<br>
-[NsSampleWork] Thread id - 1; updated 0 row with t_key = 9481<br>
-[NsSampleWork] Thread id - 2; deleted 1 row with t_key = 9481<br>
+[NsSampleWork] Thread id - 1 selected 1 row [998,Derby41        ,2.92903314E14,9572]<br>
+[NsSampleWork] Thread id - 1 selected 1 row [52,Derby41        ,2.92903314E14,9572]<br>
+[NsSampleWork] Thread id - 1 selected 1 row [52,Derby41        ,2.92903314E14,9572]<br>
+[NsSampleWork] Thread id - 2; updated 1 row with t_key = 9572<br>
+[NsSampleWork] Thread id - 1; updated 1 row with t_key = 9572<br>
+[NsSampleWork] Thread id - 2 selected 1 row [53,Derby41        ,2.92903314E14,9572]<br>
 [NsSampleWork] Thread id - 1; inserted 1 row.<br>
-[NsSampleWork] Thread id - 1; updated 1 row with t_key = 9150<br>
 [NsSampleWork] Thread id - 1; closed connection to the database.<br>
 [NsSampleClientThread] Thread id - 1; finished all tasks.<br>
-[NsSampleWork] Thread id - 2 selected 1 row [57,Derby18        ,7.873628,9150]<br>
-[NsSampleWork] Thread id - 2; updated 1 row with t_key = 9150<br>
-[NsSampleWork] Thread id - 2 selected 1 row [58,Derby18        ,7.873628,9150]<br>
+[NsSampleWork] Thread id - 2; deleted 1 row with t_key = 9572<br>
+[NsSampleWork] Thread id - 2 selected 1 row [923,Derby14        ,4122.9033,9180]<br>
 [NsSampleWork] Thread id - 2; inserted 1 row.<br>
-[NsSampleWork] Thread id - 2 selected 1 row [58,Derby18        ,7.873628,9150]<br>
+[NsSampleWork] Thread id - 2 selected 1 row [923,Derby14        ,4122.9033,9180]<br>
 [NsSampleWork] Thread id - 2; inserted 1 row.<br>
-[NsSampleWork] Thread id - 2; updated 1 row with t_key = 9150<br>
-[NsSampleWork] Thread id - 2 selected 1 row [61,Derby18        ,7.873628,9150]<br>
+[NsSampleWork] Thread id - 2 selected 1 row [923,Derby14        ,4122.9033,9180]<br>
+[NsSampleWork] Thread id - 2 selected 1 row [923,Derby14        ,4122.9033,9180]<br>
 [NsSampleWork] Thread id - 2; closed connection to the database.<br>
 [NsSampleClientThread] Thread id - 2; finished all tasks.<br>
 [NsSample] Shutting down network server.<br>
 Connection number: 4.<br>
 Shutdown successful.<br>
-[NsSample] End of Network server demo.</tt>
+[NsSample] End of Network server demo.<br>
+<br>
+</tt>
 
 <P>Running the demo program will also create new directories and files:</P>
 <UL>

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=190803&r1=190802&r2=190803&view=diff
==============================================================================
--- incubator/derby/code/trunk/java/demo/nserverdemo/simpleserversample.html (original)
+++ incubator/derby/code/trunk/java/demo/nserverdemo/simpleserversample.html Wed Jun 15 13:49:32
2005
@@ -92,7 +92,24 @@
 <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>
+
+<tt>
+Starting Network Server<br>
+Testing if Network Server is up and running!<br>
+Derby Network Server now running<br>
+Got an embedded connection.<br>
+Testing embedded connection by executing a sample query <br>
+number of rows in sys.systables = 16<br>
+<br>
+While my app is busy with embedded work, ij might connect like this:<br>
+<br>
+        $ java -Dij.user=me -Dij.password=pw -Dij.protocol=jdbc:derby://localhost:1527/ org.apache.derby.tools.ij<br>
+        ij> connect 'NSSimpleDB';<br>
+<br>
+<br>
+Clients can continue to connect: <br>
+Press [Enter] to stop Server<br>
+</tt>
 
 <p>Running this program will also create new directories and files:</p>
 
@@ -112,7 +129,7 @@
 <p>This program:</p>
 
 <ul>
- <li>loads the DB2 JDBC Universal Driver</li>
+ <li>loads the DB2 JDBC Universal Driver or the Derby Network Client JDBC 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>
@@ -134,19 +151,38 @@
  <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>derbyclient.jar</tt><br>This jar file must be in your CLASSPATH
to use t
+he Derby Client Network JDBC Driver.</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>
+<pre><tt>java SimpleNetworkClientSample [driverType]</tt></pre>
+<ul>
+<li>Where the possible values for driverType are:
+<ul>
+<li>derbyClient (default)
+<li>jccjdbcclient
+</ul>
+</ul>
 </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>
+<tt>
+Starting Sample client program <br>
+Got a client connection via the DriverManager.<br>
+connection from datasource; getDriverName = Apache Derby Network Client JDBC Driver<br>
+Got a client connection via a DataSource.<br>
+Testing the connection obtained via DriverManager by executing a sample query <br>
+number of rows in sys.systables = 16<br>
+Testing the connection obtained via a DataSource by executing a sample query <br>
+number of rows in sys.systables = 16<br>
+Goodbye!<br>
+</tt>
 
 </body>
 

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=190803&r1=190802&r2=190803&view=diff
==============================================================================
--- incubator/derby/code/trunk/java/demo/simple/SimpleApp.java (original)
+++ incubator/derby/code/trunk/java/demo/simple/SimpleApp.java Wed Jun 15 13:49:32 2005
@@ -44,6 +44,7 @@
  *
  * <p>When you run this application, give one of the following arguments:
  *    * embedded (default, if none specified)
+ *    * derbyclient (will use the Net client driver to access Network Server)
  *    * jccjdbcclient (if Derby is running embedded in the JCC Server framework)
  *
  * @author janet
@@ -238,6 +239,12 @@
                 framework = "jccjdbc";
                 driver = "com.ibm.db2.jcc.DB2Driver";
                 protocol = "jdbc:derby:net://localhost:1527/";
+            }
+            if (args[index].equalsIgnoreCase("derbyclient"))
+            {
+                framework = "derbyclient";
+                driver = "org.apache.derby.jdbc.ClientDriver";
+                protocol = "jdbc:derby://localhost:1527/";
             }
         }
     }



Mime
View raw message