You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by jb...@apache.org on 2005/05/02 08:26:03 UTC

svn commit: r165585 [42/42] - in /incubator/derby/code/trunk/java/client/org/apache/derby: client/ client/am/ client/net/ client/resources/ jdbc/

Modified: incubator/derby/code/trunk/java/client/org/apache/derby/client/resources/Resources.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/client/org/apache/derby/client/resources/Resources.java?rev=165585&r1=165584&r2=165585&view=diff
==============================================================================
--- incubator/derby/code/trunk/java/client/org/apache/derby/client/resources/Resources.java (original)
+++ incubator/derby/code/trunk/java/client/org/apache/derby/client/resources/Resources.java Sun May  1 23:25:59 2005
@@ -22,83 +22,70 @@
 
 
 /**
- * <p>
- * This is the default (English) resource bundle.
- * You can provide your own locale-specific bundle
- * with an ISO language suffix appended to the class name for
- * your language.  Additional or replacement locale-specific
- * resource bundles must reside in the <code>org.apache.derby.client.resources</code>
- * package.
- * <p>
+ * <p/>
+ * This is the default (English) resource bundle. You can provide your own locale-specific bundle with an ISO language
+ * suffix appended to the class name for your language.  Additional or replacement locale-specific resource bundles must
+ * reside in the <code>org.apache.derby.client.resources</code> package.
+ * <p/>
  * The driver locates the appropriate resource bundle for your locale by using
  * <pre>
  * java.util.ResourceBundle.getBundle ("org.apache.derby.client.resources.Resources");
  * </pre>
- * Using the ClassLoader, this call in turn looks for the appropriate bundle
- * as a .class file in the following order based on your locale:
- * <ol>
- * <li>Resources_language_country_variant
- * <li>Resources_language_country
- * <li>Resources_language
- * <li>Resources (this is the default bundle shipped with the Derby Client)
- * </ol>
- * <p>
- * <b>Note for bundle designers:</b>
- * All resource strings are processed by
- * {@link java.text.MessageFormat#format(String, Object[]) java.text.MessageFormat.format(String, Object[])},
- * so all occurrences of the {, } and ' characters in resource strings must
- * be delimited with quotes as '{', or '}' for the { and } characters,
- * and '' for the ' character.
+ * Using the ClassLoader, this call in turn looks for the appropriate bundle as a .class file in the following order
+ * based on your locale: <ol> <li>Resources_language_country_variant <li>Resources_language_country
+ * <li>Resources_language <li>Resources (this is the default bundle shipped with the Derby Client) </ol>
+ * <p/>
+ * <b>Note for bundle designers:</b> All resource strings are processed by {@link java.text.MessageFormat#format(String,
+        * Object[]) java.text.MessageFormat.format(String, Object[])}, so all occurrences of the {, } and ' characters in
+ * resource strings must be delimited with quotes as '{', or '}' for the { and } characters, and '' for the ' character.
  * For details see the Sun javadocs for class {@link java.text.MessageFormat java.text.MessageFormat}.
  *
  * @see java.util.Locale
  * @see java.util.ResourceBundle
- **/
-public class Resources extends java.util.ListResourceBundle
-{
-
-  final static private Object[][] resources__ =
-  {
-    // *******************************
-    // *** Miscellaneous text keys ***
-    // *******************************
-    {ResourceKeys.driverOriginationIndicator,
-     "[derby] "},
-
-    {ResourceKeys.engineOriginationIndicator,
-     "[derby] "},
-
-    {ResourceKeys.companyName,
-     "Apache Software Foundation"},
-
-    // ********************************
-    // *** Driver.getPropertyInfo() descriptions ***
-    // ********************************
-
-    {ResourceKeys.propertyDescription__user,
-     "The user name for the connection"},
-
-    {ResourceKeys.propertyDescription__password,
-     "The user''s password for the connection"},
-
-    {ResourceKeys.propertyDescription__characterEncoding,
-     "The character encoding for the connection"},
-
-    {ResourceKeys.propertyDescription__planName,
-     "The plan name for the connection"},
-
-    // ********************************
-    // *** Missing Resource Exception ***
-    // ********************************
-    {ResourceKeys.missingResource__01,
-     "No resource for key {0} could be found in resource bundle {1}."},
-  };
-
-  /**
-   * Extracts an array of key, resource pairs for this bundle.
-   **/
-  public Object[][] getContents()
-  {
-    return resources__;
-  }
+ */
+public class Resources extends java.util.ListResourceBundle {
+
+    final static private Object[][] resources__ =
+            {
+                // *******************************
+                // *** Miscellaneous text keys ***
+                // *******************************
+                {ResourceKeys.driverOriginationIndicator,
+                 "[derby] "},
+
+                {ResourceKeys.engineOriginationIndicator,
+                 "[derby] "},
+
+                {ResourceKeys.companyName,
+                 "Apache Software Foundation"},
+
+                // ********************************
+                // *** Driver.getPropertyInfo() descriptions ***
+                // ********************************
+
+                {ResourceKeys.propertyDescription__user,
+                 "The user name for the connection"},
+
+                {ResourceKeys.propertyDescription__password,
+                 "The user''s password for the connection"},
+
+                {ResourceKeys.propertyDescription__characterEncoding,
+                 "The character encoding for the connection"},
+
+                {ResourceKeys.propertyDescription__planName,
+                 "The plan name for the connection"},
+
+                // ********************************
+                // *** Missing Resource Exception ***
+                // ********************************
+                {ResourceKeys.missingResource__01,
+                 "No resource for key {0} could be found in resource bundle {1}."},
+            };
+
+    /**
+     * Extracts an array of key, resource pairs for this bundle.
+     */
+    public Object[][] getContents() {
+        return resources__;
+    }
 }

Modified: incubator/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientConnectionPoolDataSource.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientConnectionPoolDataSource.java?rev=165585&r1=165584&r2=165585&view=diff
==============================================================================
--- incubator/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientConnectionPoolDataSource.java (original)
+++ incubator/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientConnectionPoolDataSource.java Sun May  1 23:25:59 2005
@@ -21,71 +21,83 @@
 package org.apache.derby.jdbc;
 
 import org.apache.derby.client.ClientPooledConnection;
+
 /**
- * ClientConnectionPoolDataSource is a factory for PooledConnection objects.
- * An object that implements this interface will typically be registered with
- * a naming service that is based on the Java Naming and Directory Interface (JNDI).
+ * ClientConnectionPoolDataSource is a factory for PooledConnection objects. An object that implements this interface
+ * will typically be registered with a naming service that is based on the Java Naming and Directory Interface (JNDI).
  */
 public class ClientConnectionPoolDataSource extends ClientDataSource implements javax.sql.ConnectionPoolDataSource,
-                                                                      java.io.Serializable,
-                                                                      javax.naming.Referenceable
-{
-  static final long serialVersionUID = -539234282156481377L;
-  public static final String className__ = "org.apache.derby.jdbc.ClientConnectionPoolDataSource";
-
-  private String password = null;
-  synchronized public void setPassword (String password) { this.password = password; }
-  public final static String propertyKey_password = "password";
-
-  // deprecated.  do not use.  this member remains only for serial compatibility.
-  // this member should never be used.  pre-empted by super.traceFileSuffixIndex_.
-  // private int traceFileSuffixIndex = 0;
-
-  public ClientConnectionPoolDataSource ()
-  { super(); }
-
-  // ---------------------------interface methods-------------------------------
-
-  // Attempt to establish a physical database connection that can be used as a pooled connection.
-  public javax.sql.PooledConnection getPooledConnection () throws java.sql.SQLException
-  {
-    org.apache.derby.client.am.LogWriter dncLogWriter = super.computeDncLogWriterForNewConnection ("_cpds");
-    if (dncLogWriter != null) dncLogWriter.traceEntry (this, "getPooledConnection");
-    javax.sql.PooledConnection pooledConnection = getPooledConnectionX (dncLogWriter, this, this.user, this.password);
-    if (dncLogWriter != null) dncLogWriter.traceExit (this, "getPooledConnection", pooledConnection);
-    return pooledConnection;
-  }
-
-  // Standard method that establishes the initial physical connection using CPDS properties.
-  public javax.sql.PooledConnection getPooledConnection (String user,
-                                                         String password) throws java.sql.SQLException
-  {
-    org.apache.derby.client.am.LogWriter dncLogWriter = super.computeDncLogWriterForNewConnection ("_cpds");
-    if (dncLogWriter != null) dncLogWriter.traceEntry (this, "getPooledConnection", user, "<escaped>");
-    javax.sql.PooledConnection pooledConnection = getPooledConnectionX (dncLogWriter, this, user, password);
-    if (dncLogWriter != null) dncLogWriter.traceExit (this, "getPooledConnection", pooledConnection);
-    return pooledConnection;
-  }
-
-  //  method that establishes the initial physical connection using DS properties instead of CPDS properties.
-  public javax.sql.PooledConnection getPooledConnection (ClientDataSource ds,
-                                                         String user,
-                                                         String password) throws java.sql.SQLException
-  {
-    org.apache.derby.client.am.LogWriter dncLogWriter = ds.computeDncLogWriterForNewConnection ("_cpds");
-    if (dncLogWriter != null) dncLogWriter.traceEntry (this, "getPooledConnection", ds, user, "<escaped>");
-    javax.sql.PooledConnection pooledConnection = getPooledConnectionX (dncLogWriter, ds, user, password);
-    if (dncLogWriter != null) dncLogWriter.traceExit (this, "getPooledConnection", pooledConnection);
-    return pooledConnection;
-  }
-
-  //  method that establishes the initial physical connection
-  // using DS properties instead of CPDS properties.
-  private javax.sql.PooledConnection getPooledConnectionX (org.apache.derby.client.am.LogWriter dncLogWriter,
-                                                           ClientDataSource ds,
-                                                           String user,
-                                                           String password) throws java.sql.SQLException
-  {
-    return new ClientPooledConnection (ds, dncLogWriter, user, password);
-  }
+        java.io.Serializable,
+        javax.naming.Referenceable {
+    static final long serialVersionUID = -539234282156481377L;
+    public static final String className__ = "org.apache.derby.jdbc.ClientConnectionPoolDataSource";
+
+    private String password = null;
+
+    synchronized public void setPassword(String password) {
+        this.password = password;
+    }
+
+    public final static String propertyKey_password = "password";
+
+    // deprecated.  do not use.  this member remains only for serial compatibility.
+    // this member should never be used.  pre-empted by super.traceFileSuffixIndex_.
+    // private int traceFileSuffixIndex = 0;
+
+    public ClientConnectionPoolDataSource() {
+        super();
+    }
+
+    // ---------------------------interface methods-------------------------------
+
+    // Attempt to establish a physical database connection that can be used as a pooled connection.
+    public javax.sql.PooledConnection getPooledConnection() throws java.sql.SQLException {
+        org.apache.derby.client.am.LogWriter dncLogWriter = super.computeDncLogWriterForNewConnection("_cpds");
+        if (dncLogWriter != null) {
+            dncLogWriter.traceEntry(this, "getPooledConnection");
+        }
+        javax.sql.PooledConnection pooledConnection = getPooledConnectionX(dncLogWriter, this, this.user, this.password);
+        if (dncLogWriter != null) {
+            dncLogWriter.traceExit(this, "getPooledConnection", pooledConnection);
+        }
+        return pooledConnection;
+    }
+
+    // Standard method that establishes the initial physical connection using CPDS properties.
+    public javax.sql.PooledConnection getPooledConnection(String user,
+                                                          String password) throws java.sql.SQLException {
+        org.apache.derby.client.am.LogWriter dncLogWriter = super.computeDncLogWriterForNewConnection("_cpds");
+        if (dncLogWriter != null) {
+            dncLogWriter.traceEntry(this, "getPooledConnection", user, "<escaped>");
+        }
+        javax.sql.PooledConnection pooledConnection = getPooledConnectionX(dncLogWriter, this, user, password);
+        if (dncLogWriter != null) {
+            dncLogWriter.traceExit(this, "getPooledConnection", pooledConnection);
+        }
+        return pooledConnection;
+    }
+
+    //  method that establishes the initial physical connection using DS properties instead of CPDS properties.
+    public javax.sql.PooledConnection getPooledConnection(ClientDataSource ds,
+                                                          String user,
+                                                          String password) throws java.sql.SQLException {
+        org.apache.derby.client.am.LogWriter dncLogWriter = ds.computeDncLogWriterForNewConnection("_cpds");
+        if (dncLogWriter != null) {
+            dncLogWriter.traceEntry(this, "getPooledConnection", ds, user, "<escaped>");
+        }
+        javax.sql.PooledConnection pooledConnection = getPooledConnectionX(dncLogWriter, ds, user, password);
+        if (dncLogWriter != null) {
+            dncLogWriter.traceExit(this, "getPooledConnection", pooledConnection);
+        }
+        return pooledConnection;
+    }
+
+    //  method that establishes the initial physical connection
+    // using DS properties instead of CPDS properties.
+    private javax.sql.PooledConnection getPooledConnectionX(org.apache.derby.client.am.LogWriter dncLogWriter,
+                                                            ClientDataSource ds,
+                                                            String user,
+                                                            String password) throws java.sql.SQLException {
+        return new ClientPooledConnection(ds, dncLogWriter, user, password);
+    }
 }

Modified: incubator/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientDataSource.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientDataSource.java?rev=165585&r1=165584&r2=165585&view=diff
==============================================================================
--- incubator/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientDataSource.java (original)
+++ incubator/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientDataSource.java Sun May  1 23:25:59 2005
@@ -19,14 +19,14 @@
 */
 
 package org.apache.derby.jdbc;
+
 import org.apache.derby.client.ClientBaseDataSource;
 
 /**
- * ClientDataSource is a simple data source implementation that can be used
- * for establishing connections in a non-pooling, non-distributed environment.
- * The class ClientDataSource can be used in a connection pooling environment,
+ * ClientDataSource is a simple data source implementation that can be used for establishing connections in a
+ * non-pooling, non-distributed environment. The class ClientDataSource can be used in a connection pooling environment,
  * and the class ClientXADataSource can be used in a distributed, and pooling environment.
- * <p>
+ * <p/>
  * The example below registers a DNC data source object with a JNDI naming service.
  * <pre>
  * org.apache.derby.client.ClientDataSource dataSource = new org.apache.derby.client.ClientDataSource ();
@@ -35,282 +35,333 @@
  * javax.naming.Context context = new javax.naming.InitialContext();
  * context.bind ("jdbc/my_datasource_name", dataSource);
  * </pre>
- * The first line of code in the example creates a data source object.
- * The next two lines initialize the data source's properties.
- * Then a Java object that references the initial JNDI naming
- * context is created by calling the InitialContext() constructor, which is provided by
- * JNDI. System properties (not shown) are used to tell JNDI the service provider to use.
- * The JNDI name space is hierarchical, similar to the directory structure of many file
- * systems. The data source object is bound to a logical JNDI name by calling Context.bind().
- * In this case the JNDI name identifies a subcontext, "jdbc", of the root
- * naming context and a logical name, "my_datasource_name", within the jdbc subcontext. This
- * is all of the code required to deploy a data source object within JNDI.
- * This example is provided mainly for illustrative purposes. We expect
- * that developers or system administrators will normally use a GUI tool to deploy a data
- * source object.
- * <p>
- * Once a data source has been registered with JNDI, it can then be used by a JDBC application,
- * as is shown in the following example.
+ * The first line of code in the example creates a data source object. The next two lines initialize the data source's
+ * properties. Then a Java object that references the initial JNDI naming context is created by calling the
+ * InitialContext() constructor, which is provided by JNDI. System properties (not shown) are used to tell JNDI the
+ * service provider to use. The JNDI name space is hierarchical, similar to the directory structure of many file
+ * systems. The data source object is bound to a logical JNDI name by calling Context.bind(). In this case the JNDI name
+ * identifies a subcontext, "jdbc", of the root naming context and a logical name, "my_datasource_name", within the jdbc
+ * subcontext. This is all of the code required to deploy a data source object within JNDI. This example is provided
+ * mainly for illustrative purposes. We expect that developers or system administrators will normally use a GUI tool to
+ * deploy a data source object.
+ * <p/>
+ * Once a data source has been registered with JNDI, it can then be used by a JDBC application, as is shown in the
+ * following example.
  * <pre>
  * javax.naming.Context context = new javax.naming.InitialContext ();
  * javax.sql.DataSource dataSource = (javax.sql.DataSource) context.lookup ("jdbc/my_datasource_name");
  * java.sql.Connection connection = dataSource.getConnection ("user", "password");
  * </pre>
- * The first line in the example creates a Java object that references the initial JNDI naming
- * context. Next, the initial naming context is used to do a lookup operation using the
- * logical name of the data source. The Context.lookup() method returns a reference to
- * a Java Object, which is narrowed to a javax.sql.DataSource object. In the last line,
- * the DataSource.getConnection() method is called to produce a database connection.
- * <p>
+ * The first line in the example creates a Java object that references the initial JNDI naming context. Next, the
+ * initial naming context is used to do a lookup operation using the logical name of the data source. The
+ * Context.lookup() method returns a reference to a Java Object, which is narrowed to a javax.sql.DataSource object. In
+ * the last line, the DataSource.getConnection() method is called to produce a database connection.
+ * <p/>
  * This simple data source subclass of ClientBaseDataSource maintains it's own private <code>password</code> property.
- * <p>
- * The specified password, along with the user,
- * is validated by DERBY.  This property
- * can be overwritten by specifing the password parameter on the
- * DataSource.getConnection() method call.
- * <p>
- * This password property is not declared transient, and therefore may be serialized
- * to a file in clear-text, or stored to a JNDI server in clear-text when the data source is saved.
- * Care must taken by the user to prevent security breaches.
- * <p>
- *
+ * <p/>
+ * The specified password, along with the user, is validated by DERBY.  This property can be overwritten by specifing
+ * the password parameter on the DataSource.getConnection() method call.
+ * <p/>
+ * This password property is not declared transient, and therefore may be serialized to a file in clear-text, or stored
+ * to a JNDI server in clear-text when the data source is saved. Care must taken by the user to prevent security
+ * breaches.
+ * <p/>
  */
 public class ClientDataSource extends ClientBaseDataSource implements javax.sql.DataSource,
-                                                                      java.io.Serializable,
-                                                                      javax.naming.Referenceable
-{
-  private final static long serialVersionUID = 1894299584216955553L;
-  public static final String className__ = "org.apache.derby.jdbc.ClientDataSource";
-
-  // If a newer version of a serialized object has to be compatible with an older version, it is important that the newer version abides
-  // by the rules for compatible and incompatible changes.
-  //
-  // A compatible change is one that can be made to a new version of the class, which still keeps the stream compatible with older
-  // versions of the class. Examples of compatible changes are:
-  //
-  // Addition of new fields or classes does not affect serialization, as any new data in the stream is simply ignored by older
-  // versions. When the instance of an older version of the class is deserialized, the newly added field will be set to its default
-  // value.
-  // You can field change access modifiers like private, public, protected or package as they are not reflected to the serial
-  // stream.
-  // You can change a transient or static field to a non-transient or non-static field, as it is similar to adding a field.
-  // You can change the access modifiers for constructors and methods of the class. For instance a previously private method
-  // can now be made public, an instance method can be changed to static, etc. The only exception is that you cannot change
-  // the default signatures for readObject() and writeObject() if you are implementing custom serialization. The serialization
-  // process looks at only instance data, and not the methods of a class.
-  //
-  // Changes which would render the stream incompatible are:
-  //
-  // Once a class implements the Serializable interface, you cannot later make it implement the Externalizable interface, since
-  // this will result in the creation of an incompatible stream.
-  // Deleting fields can cause a problem. Now, when the object is serialized, an earlier version of the class would set the old
-  // field to its default value since nothing was available within the stream. Consequently, this default data may lead the newly
-  // created object to assume an invalid state.
-  // Changing a non-static into static or non-transient into transient is not permitted as it is equivalent to deleting fields.
-  // You also cannot change the field types within a class, as this would cause a failure when attempting to read in the original
-  // field into the new field.
-  // You cannot alter the position of the class in the class hierarchy. Since the fully-qualified class name is written as part of
-  // the bytestream, this change will result in the creation of an incompatible stream.
-  // You cannot change the name of the class or the package it belongs to, as that information is written to the stream during
-  // serialization.
-
-  private String password = null;
-  synchronized public void setPassword (String password) { this.password = password; }
-
-
-  /**
-   * Creates a simple DERBY data source with default property values
-   * for a non-pooling, non-distributed environment.
-   * No particular DatabaseName or other properties are associated with the data source.
-   * <p>
-   * Every Java Bean should provide a constructor with no arguments
-   * since many beanboxes attempt to instantiate a bean by invoking
-   * its no-argument constructor.
-   *
-   */
-  public ClientDataSource () { super(); }
-
-
-  // ---------------------------interface methods-------------------------------
-
-  /**
-   * Attempt to establish a database connection in a non-pooling, non-distributed environment.
-   *
-   * @return a Connection to the database
-   * @throws java.sql.SQLException if a database-access error occurs.
-   **/
-  public java.sql.Connection getConnection () throws java.sql.SQLException
-  { return getConnection (this.user, this.password); }
-
-  /**
-   * Attempt to establish a database connection in a non-pooling, non-distributed environment.
-   *
-   * @param user the database user on whose behalf the Connection is being made
-   * @param password the user's password
-   * @return a Connection to the database
-   * @throws java.sql.SQLException if a database-access error occurs.
-   **/
-  public java.sql.Connection getConnection (String user, String password) throws java.sql.SQLException
-  {
-    // Jdbc 2 connections will write driver trace info on a
-    // datasource-wide basis using the jdbc 2 data source log writer.
-    // This log writer may be narrowed to the connection-level
-    // This log writer will be passed to the agent constructor.
-
-    org.apache.derby.client.am.LogWriter dncLogWriter = super.computeDncLogWriterForNewConnection ("_sds");
-	updateDataSourceValues(tokenizeAttributes(connectionAttributes,null));
-    return
-        new org.apache.derby.client.net.NetConnection (
-          (org.apache.derby.client.net.NetLogWriter) dncLogWriter,
-          user,
-          password,
-          this,
-          -1,
-          false);
-  }
-
-	/*
-	 * Properties to be seen by Bean - access thru reflection.
-	 */
-
-	// -- Stardard JDBC DataSource Properties
-	
-	public synchronized void setDatabaseName (String databaseName) { this.databaseName = databaseName; }
-	public String getDatabaseName () { return this.databaseName; }
-	
-	
-	public synchronized void setDataSourceName (String dataSourceName) { this.dataSourceName = dataSourceName; }
-	public String getDataSourceName () { return this.dataSourceName; }
-	
-  public synchronized void setDescription (String description) { this.description = description; }
-  public String getDescription () { return this.description; }
-
-
-	public synchronized void setPortNumber (int portNumber) { this.portNumber = portNumber; }
-	public int getPortNumber () { return this.portNumber; }
-	
-	public synchronized void setServerName (String serverName) { this.serverName = serverName; }
-	public String getServerName () { return this.serverName; }
-
-
-	public synchronized void setUser (String user) { this.user = user; }
-	public String getUser () { return this.user; }
-	
-	synchronized public void setRetrieveMessageText (boolean retrieveMessageText) { this.retrieveMessageText = retrieveMessageText; }
-	public boolean getRetrieveMessageText () { return this.retrieveMessageText; }
-
-	// ---------------------------- securityMechanism -----------------------------------
-	/**
-	 *The source security mechanism to use when connecting to this data source.
-  * <p>
-  * Security mechanism options are:
-  * <ul>
-  * <li> USER_ONLY_SECURITY
-  * <li> CLEAR_TEXT_PASSWORD_SECURITY
-  * <li> ENCRYPTED_PASSWORD_SECURITY
-  * <li> ENCRYPTED_USER_AND_PASSWORD_SECURITY - both password and user are encrypted
-  * </ul>
-  * The default security mechanism is USER_ONLY SECURITY
-  * <p>
-  * If the application specifies a security
-  * mechanism then it will be the only one attempted.
-  * If the specified security mechanism is not supported by the conversation
-  * then an exception will be thrown and there will be no additional retries.
-  * <p>
-  * This property is currently only available for the  DNC driver.
-  * <p>
-  * Both user and password need to be set for all security mechanism except USER_ONLY_SECURITY 
-  */
-	// We use the NET layer constants to avoid a mapping for the NET driver.
-	public final static short USER_ONLY_SECURITY = (short) org.apache.derby.client.net.NetConfiguration.SECMEC_USRIDONL;
-	public final static short CLEAR_TEXT_PASSWORD_SECURITY = (short) org.apache.derby.client.net.NetConfiguration.SECMEC_USRIDPWD;
-	public final static short ENCRYPTED_PASSWORD_SECURITY = (short) org.apache.derby.client.net.NetConfiguration.SECMEC_USRENCPWD;
-	public final static short ENCRYPTED_USER_AND_PASSWORD_SECURITY = (short) org.apache.derby.client.net.NetConfiguration.SECMEC_EUSRIDPWD;
-	
-	synchronized public void setSecurityMechanism (short securityMechanism) { this.securityMechanism = securityMechanism; }
-	public short getSecurityMechanism () { 
-		return getUpgradedSecurityMechanism(this.securityMechanism,
-											this.password);
-	}
-
-	protected String connectionAttributes = "";
-
-	/**
- 		Set this property to pass in more Derby specific
-		connection URL attributes.
-
-		@param prop set to the list of Cloudscape connection
-		attributes separated by semi-colons.   E.g., to specify an encryption
-		bootPassword of "x8hhk2adf", and set upgrade to true, do the following: 
-		<PRE>
-			ds.setConnectionAttributes("bootPassword=x8hhk2adf;upgrade=true");
-		</PRE>
-		See Derby documentation for complete list.
-	 */
-	public final void setConnectionAttributes(String prop) {
-		 connectionAttributes = prop;
-	}
-
-	/** @return Derby specific connection URL attributes */
-	public final String getConnectionAttributes() {
-		return connectionAttributes;
-	}
-	
-
-	public final static int TRACE_NONE = 0x0;
-	public final static int TRACE_CONNECTION_CALLS = 0x1;
-	public final static int TRACE_STATEMENT_CALLS= 0x2;
-	public final static int TRACE_RESULT_SET_CALLS = 0x4;
-	public final static int TRACE_DRIVER_CONFIGURATION = 0x10;
-	public final static int TRACE_CONNECTS = 0x20;
-	public final static int TRACE_PROTOCOL_FLOWS = 0x40;
-	public final static int TRACE_RESULT_SET_META_DATA = 0x80;
-	public final static int TRACE_PARAMETER_META_DATA = 0x100;
-	public final static int TRACE_DIAGNOSTICS = 0x200;
-	public final static int TRACE_XA_CALLS = 0x800;
-  public final static int TRACE_ALL = 0xFFFFFFFF;
-	synchronized public void setTraceLevel (int traceLevel) { this.traceLevel = traceLevel; }
-	public int getTraceLevel () { return this.traceLevel; }
-	
-
-	public synchronized void setTraceFile (String traceFile) { this.traceFile = traceFile; }
-	public String getTraceFile () { return this.traceFile; }
-
-
-	public synchronized void setTraceDirectory (String traceDirectory) { this.traceDirectory = traceDirectory; }
-	public String getTraceDirectory () { return this.traceDirectory; }
-
-	synchronized public void setTraceFileAppend (boolean traceFileAppend) { this.traceFileAppend = traceFileAppend; }
-	public boolean getTraceFileAppend () { return this.traceFileAppend; }
-
-
-
-
-	// --- private helper methods
-
-	
-	/**
-	 * The dataSource keeps individual fields for the values that are 
-	 * relevant to the client. These need to be updated when 
-	 * set connection attributes is called.
-	 */
-	private void updateDataSourceValues(java.util.Properties prop)
-	{
-		if ( prop.containsKey(propertyKey_user))
-			setUser(getUser(prop));
-		if ( prop.containsKey(propertyKey_securityMechanism))
-			 setSecurityMechanism(getSecurityMechanism(prop));
-		if ( prop.containsKey(propertyKey_traceFile))
-			 setTraceFile(getTraceFile(prop));
-		if ( prop.containsKey(propertyKey_traceDirectory))
-			 setTraceDirectory(getTraceDirectory(prop));
-		if ( prop.containsKey(propertyKey_traceFileAppend))
-			setTraceFileAppend(getTraceFileAppend(prop));
-		if ( prop.containsKey(propertyKey_securityMechanism))
-			setSecurityMechanism(getSecurityMechanism(prop));
-		if ( prop.containsKey(propertyKey_retrieveMessageText))
-			setRetrieveMessageText(getRetrieveMessageText(prop));
-	}
+        java.io.Serializable,
+        javax.naming.Referenceable {
+    private final static long serialVersionUID = 1894299584216955553L;
+    public static final String className__ = "org.apache.derby.jdbc.ClientDataSource";
+
+    // If a newer version of a serialized object has to be compatible with an older version, it is important that the newer version abides
+    // by the rules for compatible and incompatible changes.
+    //
+    // A compatible change is one that can be made to a new version of the class, which still keeps the stream compatible with older
+    // versions of the class. Examples of compatible changes are:
+    //
+    // Addition of new fields or classes does not affect serialization, as any new data in the stream is simply ignored by older
+    // versions. When the instance of an older version of the class is deserialized, the newly added field will be set to its default
+    // value.
+    // You can field change access modifiers like private, public, protected or package as they are not reflected to the serial
+    // stream.
+    // You can change a transient or static field to a non-transient or non-static field, as it is similar to adding a field.
+    // You can change the access modifiers for constructors and methods of the class. For instance a previously private method
+    // can now be made public, an instance method can be changed to static, etc. The only exception is that you cannot change
+    // the default signatures for readObject() and writeObject() if you are implementing custom serialization. The serialization
+    // process looks at only instance data, and not the methods of a class.
+    //
+    // Changes which would render the stream incompatible are:
+    //
+    // Once a class implements the Serializable interface, you cannot later make it implement the Externalizable interface, since
+    // this will result in the creation of an incompatible stream.
+    // Deleting fields can cause a problem. Now, when the object is serialized, an earlier version of the class would set the old
+    // field to its default value since nothing was available within the stream. Consequently, this default data may lead the newly
+    // created object to assume an invalid state.
+    // Changing a non-static into static or non-transient into transient is not permitted as it is equivalent to deleting fields.
+    // You also cannot change the field types within a class, as this would cause a failure when attempting to read in the original
+    // field into the new field.
+    // You cannot alter the position of the class in the class hierarchy. Since the fully-qualified class name is written as part of
+    // the bytestream, this change will result in the creation of an incompatible stream.
+    // You cannot change the name of the class or the package it belongs to, as that information is written to the stream during
+    // serialization.
+
+    private String password = null;
+
+    synchronized public void setPassword(String password) {
+        this.password = password;
+    }
+
+
+    /**
+     * Creates a simple DERBY data source with default property values for a non-pooling, non-distributed environment.
+     * No particular DatabaseName or other properties are associated with the data source.
+     * <p/>
+     * Every Java Bean should provide a constructor with no arguments since many beanboxes attempt to instantiate a bean
+     * by invoking its no-argument constructor.
+     */
+    public ClientDataSource() {
+        super();
+    }
+
+
+    // ---------------------------interface methods-------------------------------
+
+    /**
+     * Attempt to establish a database connection in a non-pooling, non-distributed environment.
+     *
+     * @return a Connection to the database
+     *
+     * @throws java.sql.SQLException if a database-access error occurs.
+     */
+    public java.sql.Connection getConnection() throws java.sql.SQLException {
+        return getConnection(this.user, this.password);
+    }
+
+    /**
+     * Attempt to establish a database connection in a non-pooling, non-distributed environment.
+     *
+     * @param user     the database user on whose behalf the Connection is being made
+     * @param password the user's password
+     *
+     * @return a Connection to the database
+     *
+     * @throws java.sql.SQLException if a database-access error occurs.
+     */
+    public java.sql.Connection getConnection(String user, String password) throws java.sql.SQLException {
+        // Jdbc 2 connections will write driver trace info on a
+        // datasource-wide basis using the jdbc 2 data source log writer.
+        // This log writer may be narrowed to the connection-level
+        // This log writer will be passed to the agent constructor.
+
+        org.apache.derby.client.am.LogWriter dncLogWriter = super.computeDncLogWriterForNewConnection("_sds");
+        updateDataSourceValues(tokenizeAttributes(connectionAttributes, null));
+        return
+                new org.apache.derby.client.net.NetConnection((org.apache.derby.client.net.NetLogWriter) dncLogWriter,
+                        user,
+                        password,
+                        this,
+                        -1,
+                        false);
+    }
+
+    /*
+     * Properties to be seen by Bean - access thru reflection.
+     */
+
+    // -- Stardard JDBC DataSource Properties
+
+    public synchronized void setDatabaseName(String databaseName) {
+        this.databaseName = databaseName;
+    }
+
+    public String getDatabaseName() {
+        return this.databaseName;
+    }
+
+
+    public synchronized void setDataSourceName(String dataSourceName) {
+        this.dataSourceName = dataSourceName;
+    }
+
+    public String getDataSourceName() {
+        return this.dataSourceName;
+    }
+
+    public synchronized void setDescription(String description) {
+        this.description = description;
+    }
+
+    public String getDescription() {
+        return this.description;
+    }
+
+
+    public synchronized void setPortNumber(int portNumber) {
+        this.portNumber = portNumber;
+    }
+
+    public int getPortNumber() {
+        return this.portNumber;
+    }
+
+    public synchronized void setServerName(String serverName) {
+        this.serverName = serverName;
+    }
+
+    public String getServerName() {
+        return this.serverName;
+    }
+
+
+    public synchronized void setUser(String user) {
+        this.user = user;
+    }
+
+    public String getUser() {
+        return this.user;
+    }
+
+    synchronized public void setRetrieveMessageText(boolean retrieveMessageText) {
+        this.retrieveMessageText = retrieveMessageText;
+    }
+
+    public boolean getRetrieveMessageText() {
+        return this.retrieveMessageText;
+    }
+
+    // ---------------------------- securityMechanism -----------------------------------
+    /**
+     * The source security mechanism to use when connecting to this data source.
+     * <p/>
+     * Security mechanism options are: <ul> <li> USER_ONLY_SECURITY <li> CLEAR_TEXT_PASSWORD_SECURITY <li>
+     * ENCRYPTED_PASSWORD_SECURITY <li> ENCRYPTED_USER_AND_PASSWORD_SECURITY - both password and user are encrypted
+     * </ul> The default security mechanism is USER_ONLY SECURITY
+     * <p/>
+     * If the application specifies a security mechanism then it will be the only one attempted. If the specified
+     * security mechanism is not supported by the conversation then an exception will be thrown and there will be no
+     * additional retries.
+     * <p/>
+     * This property is currently only available for the  DNC driver.
+     * <p/>
+     * Both user and password need to be set for all security mechanism except USER_ONLY_SECURITY
+     */
+    // We use the NET layer constants to avoid a mapping for the NET driver.
+    public final static short USER_ONLY_SECURITY = (short) org.apache.derby.client.net.NetConfiguration.SECMEC_USRIDONL;
+    public final static short CLEAR_TEXT_PASSWORD_SECURITY = (short) org.apache.derby.client.net.NetConfiguration.SECMEC_USRIDPWD;
+    public final static short ENCRYPTED_PASSWORD_SECURITY = (short) org.apache.derby.client.net.NetConfiguration.SECMEC_USRENCPWD;
+    public final static short ENCRYPTED_USER_AND_PASSWORD_SECURITY = (short) org.apache.derby.client.net.NetConfiguration.SECMEC_EUSRIDPWD;
+
+    synchronized public void setSecurityMechanism(short securityMechanism) {
+        this.securityMechanism = securityMechanism;
+    }
+
+    public short getSecurityMechanism() {
+        return getUpgradedSecurityMechanism(this.securityMechanism,
+                this.password);
+    }
+
+    protected String connectionAttributes = "";
+
+    /**
+     * Set this property to pass in more Derby specific connection URL attributes.
+     *
+     * @param prop set to the list of Cloudscape connection attributes separated by semi-colons.   E.g., to specify an
+     *             encryption bootPassword of "x8hhk2adf", and set upgrade to true, do the following: <PRE>
+     *             ds.setConnectionAttributes("bootPassword=x8hhk2adf;upgrade=true"); </PRE> See Derby documentation for
+     *             complete list.
+     */
+    public final void setConnectionAttributes(String prop) {
+        connectionAttributes = prop;
+    }
+
+    /**
+     * @return Derby specific connection URL attributes
+     */
+    public final String getConnectionAttributes() {
+        return connectionAttributes;
+    }
+
+
+    public final static int TRACE_NONE = 0x0;
+    public final static int TRACE_CONNECTION_CALLS = 0x1;
+    public final static int TRACE_STATEMENT_CALLS = 0x2;
+    public final static int TRACE_RESULT_SET_CALLS = 0x4;
+    public final static int TRACE_DRIVER_CONFIGURATION = 0x10;
+    public final static int TRACE_CONNECTS = 0x20;
+    public final static int TRACE_PROTOCOL_FLOWS = 0x40;
+    public final static int TRACE_RESULT_SET_META_DATA = 0x80;
+    public final static int TRACE_PARAMETER_META_DATA = 0x100;
+    public final static int TRACE_DIAGNOSTICS = 0x200;
+    public final static int TRACE_XA_CALLS = 0x800;
+    public final static int TRACE_ALL = 0xFFFFFFFF;
+
+    synchronized public void setTraceLevel(int traceLevel) {
+        this.traceLevel = traceLevel;
+    }
+
+    public int getTraceLevel() {
+        return this.traceLevel;
+    }
+
+
+    public synchronized void setTraceFile(String traceFile) {
+        this.traceFile = traceFile;
+    }
+
+    public String getTraceFile() {
+        return this.traceFile;
+    }
+
+
+    public synchronized void setTraceDirectory(String traceDirectory) {
+        this.traceDirectory = traceDirectory;
+    }
+
+    public String getTraceDirectory() {
+        return this.traceDirectory;
+    }
+
+    synchronized public void setTraceFileAppend(boolean traceFileAppend) {
+        this.traceFileAppend = traceFileAppend;
+    }
+
+    public boolean getTraceFileAppend() {
+        return this.traceFileAppend;
+    }
+
+
+
+
+    // --- private helper methods
+
+
+    /**
+     * The dataSource keeps individual fields for the values that are relevant to the client. These need to be updated
+     * when set connection attributes is called.
+     */
+    private void updateDataSourceValues(java.util.Properties prop) {
+        if (prop.containsKey(propertyKey_user)) {
+            setUser(getUser(prop));
+        }
+        if (prop.containsKey(propertyKey_securityMechanism)) {
+            setSecurityMechanism(getSecurityMechanism(prop));
+        }
+        if (prop.containsKey(propertyKey_traceFile)) {
+            setTraceFile(getTraceFile(prop));
+        }
+        if (prop.containsKey(propertyKey_traceDirectory)) {
+            setTraceDirectory(getTraceDirectory(prop));
+        }
+        if (prop.containsKey(propertyKey_traceFileAppend)) {
+            setTraceFileAppend(getTraceFileAppend(prop));
+        }
+        if (prop.containsKey(propertyKey_securityMechanism)) {
+            setSecurityMechanism(getSecurityMechanism(prop));
+        }
+        if (prop.containsKey(propertyKey_retrieveMessageText)) {
+            setRetrieveMessageText(getRetrieveMessageText(prop));
+        }
+    }
 
 }
 

Modified: incubator/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientDriver.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientDriver.java?rev=165585&r1=165584&r2=165585&view=diff
==============================================================================
--- incubator/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientDriver.java (original)
+++ incubator/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientDriver.java Sun May  1 23:25:59 2005
@@ -20,276 +20,273 @@
 
 package org.apache.derby.jdbc;
 
-import org.apache.derby.client.resources.ResourceKeys;
-import org.apache.derby.client.am.ResourceUtilities;
-import org.apache.derby.client.am.Utils;
 import org.apache.derby.client.am.Configuration;
+import org.apache.derby.client.am.ResourceUtilities;
 import org.apache.derby.client.am.SqlException;
+import org.apache.derby.client.am.Utils;
 import org.apache.derby.client.am.Version;
+import org.apache.derby.client.resources.ResourceKeys;
+
+
+public class ClientDriver implements java.sql.Driver {
+    private transient int traceFileSuffixIndex_ = 0;
+
+    private final static int DERBY_REMOTE_PROTOCOL = 1;
+
+    static private SqlException exceptionsOnLoadDriver__ = null;
+    // Keep track of the registere driver so that we can deregister it if we're a stored proc.
+    static private ClientDriver registeredDriver__ = null;
+
+    static {
+        // This may possibly hit the race-condition bug of java 1.1.
+        // The Configuration static clause should execute before the following line does.
+        if (Configuration.exceptionsOnLoadResources != null) {
+            exceptionsOnLoadDriver__ =
+                    Utils.accumulateSQLException(Configuration.exceptionsOnLoadResources,
+                            exceptionsOnLoadDriver__);
+        }
+        try {
+            registeredDriver__ = new ClientDriver();
+            java.sql.DriverManager.registerDriver(registeredDriver__);
+        } catch (java.sql.SQLException e) {
+            // A null log writer is passed, because jdbc 1 sql exceptions are automatically traced
+            exceptionsOnLoadDriver__ =
+                    new SqlException(null, "Error occurred while trying to register Dnc driver with JDBC 1 Driver Manager");
+            exceptionsOnLoadDriver__.setNextException(e);
+        }
+    }
+
+    public ClientDriver() {
+    }
+
+    public java.sql.Connection connect(String url,
+                                       java.util.Properties properties) throws java.sql.SQLException {
+        if (exceptionsOnLoadDriver__ != null) {
+            throw exceptionsOnLoadDriver__;
+        }
+
+        if (properties == null) {
+            properties = new java.util.Properties();
+        }
+
+        java.util.StringTokenizer urlTokenizer =
+                new java.util.StringTokenizer(url, "/:= \t\n\r\f", true);
+
+        int protocol = tokenizeProtocol(url, urlTokenizer);
+        if (protocol == 0) {
+            return null; // unrecognized database URL prefix.
+        }
+
+        String slashOrNull = null;
+        if (protocol == DERBY_REMOTE_PROTOCOL) {
+            try {
+                slashOrNull = urlTokenizer.nextToken(":/");
+            } catch (java.util.NoSuchElementException e) {
+                // A null log writer is passed, because jdbc 1 sqlexceptions are automatically traced
+                throw new SqlException(null, e, "Invalid database url syntax: " + url);
+            }
+        }
+        String server = tokenizeServerName(urlTokenizer, url);    // "/server"
+        int port = tokenizeOptionalPortNumber(urlTokenizer, url); // "[:port]/"
+        if (port == 0) {
+            port = ClientDataSource.propertyDefault_portNumber;
+        }
+
+        // longDatabase is the databaseName and attributes.  This will be
+        // sent to network server as the databaseName
+        String database = tokenizeDatabase(urlTokenizer, url); // "database"
+        java.util.Properties augmentedProperties = tokenizeURLProperties(url, properties);
+
+
+        int traceLevel;
+        try {
+            traceLevel = ClientDataSource.getTraceLevel(augmentedProperties);
+        } catch (java.lang.NumberFormatException e) {
+            // A null log writer is passed, because jdbc 1 sqlexceptions are automatically traced
+            throw new SqlException(null, e, "trouble reading traceLevel connection property");
+        }
+
+        // Jdbc 1 connections will write driver trace info on a
+        // driver-wide basis using the jdbc 1 driver manager log writer.
+        // This log writer may be narrowed to the connection-level
+        // This log writer will be passed to the agent constructor.
+        org.apache.derby.client.am.LogWriter dncLogWriter =
+                ClientDataSource.computeDncLogWriterForNewConnection(java.sql.DriverManager.getLogWriter(),
+                        ClientDataSource.getTraceDirectory(augmentedProperties),
+                        ClientDataSource.getTraceFile(augmentedProperties),
+                        ClientDataSource.getTraceFileAppend(augmentedProperties),
+                        traceLevel,
+                        "_driver",
+                        traceFileSuffixIndex_++);
+
+        org.apache.derby.client.net.NetConnection conn =
+                new org.apache.derby.client.net.NetConnection((org.apache.derby.client.net.NetLogWriter) dncLogWriter,
+                        java.sql.DriverManager.getLoginTimeout(),
+                        server,
+                        port,
+                        database,
+                        augmentedProperties);
+        return conn;
+    }
+
+    public boolean acceptsURL(String url) throws java.sql.SQLException {
+        java.util.StringTokenizer urlTokenizer = new java.util.StringTokenizer(url, "/:=; \t\n\r\f", true);
+        int protocol = tokenizeProtocol(url, urlTokenizer);
+        return protocol != 0;
+    }
+
+    public java.sql.DriverPropertyInfo[] getPropertyInfo(String url,
+                                                         java.util.Properties properties) throws java.sql.SQLException {
+        java.sql.DriverPropertyInfo driverPropertyInfo[] = new java.sql.DriverPropertyInfo[2];
+
+        // If there are no properties set already,
+        // then create a dummy properties just to make the calls go thru.
+        if (properties == null) {
+            properties = new java.util.Properties();
+        }
 
+        driverPropertyInfo[0] =
+                new java.sql.DriverPropertyInfo(ClientDataSource.propertyKey_user,
+                        properties.getProperty(ClientDataSource.propertyKey_user, ClientDataSource.propertyDefault_user));
+
+        driverPropertyInfo[1] =
+                new java.sql.DriverPropertyInfo(ClientDataSource.propertyKey_password,
+                        properties.getProperty(ClientDataSource.propertyKey_password));
+
+        driverPropertyInfo[0].description =
+                ResourceUtilities.getResource(ResourceKeys.propertyDescription__user);
+        driverPropertyInfo[1].description =
+                ResourceUtilities.getResource(ResourceKeys.propertyDescription__password);
+
+        driverPropertyInfo[0].required = true;
+        driverPropertyInfo[1].required = false; // depending on the security mechanism
+
+        return driverPropertyInfo;
+    }
+
+    public int getMajorVersion() {
+        return Version.getMajorVersion();
+    }
+
+    public int getMinorVersion() {
+        return Version.getMinorVersion();
+    }
+
+    public boolean jdbcCompliant() {
+        return Configuration.jdbcCompliant;
+    }
+
+    // ----------------helper methods---------------------------------------------
+
+    // Tokenize one of the following:
+    //  "jdbc:derby:"
+    // and return 0 if the protcol is unrecognized
+    // return DERBY_PROTOCOL for "jdbc:derby"
+    private static int tokenizeProtocol(String url, java.util.StringTokenizer urlTokenizer) throws SqlException {
+        // Is this condition necessary, StringTokenizer constructor may do this for us
+        if (url == null) {
+            return 0;
+        }
+
+        if (urlTokenizer == null) {
+            return 0;
+        }
+
+        try {
+            String jdbc = urlTokenizer.nextToken(":");
+            if (!jdbc.equals("jdbc")) {
+                return 0;
+            }
+            if (!urlTokenizer.nextToken(":").equals(":")) {
+                return 0; // Skip over the first colon in jdbc:derby:
+            }
+            String dbname = urlTokenizer.nextToken(":");
+            int protocol = 0;
+            if (dbname.equals("derby") && (url.indexOf("derby://") != -1)) {
+                // For Derby AS need to check for // since jdbc:derby: is also the
+                // embedded prefix
+                protocol = DERBY_REMOTE_PROTOCOL;
+            } else {
+                return 0;
+            }
+
+            if (!urlTokenizer.nextToken(":").equals(":")) {
+                return 0; // Skip over the second colon in jdbc:derby:
+            }
+
+            return protocol;
+        } catch (java.util.NoSuchElementException e) {
+            return 0;
+        }
+    }
+
+    // tokenize "/server" from URL jdbc:derby://server:port/
+    // returns server name
+    private static String tokenizeServerName(java.util.StringTokenizer urlTokenizer,
+                                             String url) throws SqlException {
+        try {
+            if (!urlTokenizer.nextToken("/").equals("/"))
+            // A null log writer is passed, because jdbc 1 sqlexceptions are automatically traced
+            {
+                throw new SqlException(null, "Invalid database url syntax: " + url);
+            }
+            return urlTokenizer.nextToken("/:");
+        } catch (java.util.NoSuchElementException e) {
+            // A null log writer is passed, because jdbc 1 sqlexceptions are automatically traced
+            throw new SqlException(null, e, "Invalid database url syntax: " + url);
+        }
+    }
+
+    // tokenize "[:portNumber]/" from URL jdbc:derby://server[:port]/
+    // returns the portNumber or zero if portNumber is not specified.
+    private static int tokenizeOptionalPortNumber(java.util.StringTokenizer urlTokenizer,
+                                                  String url) throws SqlException {
+        try {
+            String firstToken = urlTokenizer.nextToken(":/");
+            if (firstToken.equals(":")) {
+                String port = urlTokenizer.nextToken("/");
+                if (!urlTokenizer.nextToken("/").equals("/")) {
+                    // A null log writer is passed, because jdbc 1 sqlexceptions are automatically traced
+                    throw new SqlException(null, "Invalid database url syntax: " + url);
+                }
+                return Integer.parseInt(port);
+            } else if (firstToken.equals("/")) {
+                return 0;
+            } else {
+                // A null log writer is passed, because jdbc 1 sqlexceptions are automatically traced
+                throw new SqlException(null, "Invalid database url syntax: " + url);
+            }
+        } catch (java.util.NoSuchElementException e) {
+            // A null log writer is passed, because jdbc 1 sqlexceptions are automatically traced
+            throw new SqlException(null, e, "Invalid database url syntax: " + url);
+        }
+    }
+
+    //return database name and attributes
+    private static String tokenizeDatabase(java.util.StringTokenizer urlTokenizer,
+                                           String url) throws SqlException {
+        try {
+            String databaseName = urlTokenizer.nextToken(" \t\n\r\f");
+            return databaseName;
+        } catch (java.util.NoSuchElementException e) {
+            // A null log writer is passed, because jdbc 1 sqlexceptions are automatically traced
+            throw new SqlException(null, e, "Invalid database url syntax: " + url);
+        }
+    }
+
+    private static java.util.Properties tokenizeURLProperties(String url,
+                                                              java.util.Properties properties)
+            throws SqlException {
+        String attributeString = null;
+        int attributeIndex = -1;
+
+        if ((url != null) &&
+                ((attributeIndex = url.indexOf(";")) != -1)) {
+            attributeString = url.substring(attributeIndex);
+        }
+        return ClientDataSource.tokenizeAttributes(attributeString, properties);
+    }
 
-public class ClientDriver implements java.sql.Driver
-{
-  private transient int traceFileSuffixIndex_ = 0;
-
-  private final static int DERBY_REMOTE_PROTOCOL = 1;
-
-  static private SqlException exceptionsOnLoadDriver__ = null;
-  // Keep track of the registere driver so that we can deregister it if we're a stored proc.
-  static private ClientDriver registeredDriver__ = null;
-
-  static {
-    // This may possibly hit the race-condition bug of java 1.1.
-    // The Configuration static clause should execute before the following line does.
-    if (Configuration.exceptionsOnLoadResources != null) {
-      exceptionsOnLoadDriver__ =
-        Utils.accumulateSQLException (Configuration.exceptionsOnLoadResources,
-                                      exceptionsOnLoadDriver__);
-    }
-    try {
-      registeredDriver__ = new ClientDriver();
-      java.sql.DriverManager.registerDriver (registeredDriver__);
-    }
-    catch (java.sql.SQLException e) {
-      // A null log writer is passed, because jdbc 1 sql exceptions are automatically traced
-      exceptionsOnLoadDriver__ =
-        new SqlException (null, "Error occurred while trying to register Dnc driver with JDBC 1 Driver Manager");
-      exceptionsOnLoadDriver__.setNextException (e);
-    }
-  }
-
-  public ClientDriver() {}
-
-  public java.sql.Connection connect (String url,
-                                      java.util.Properties properties) throws java.sql.SQLException
-  {
-    if (exceptionsOnLoadDriver__ != null) throw exceptionsOnLoadDriver__;
-
-    if (properties == null) properties = new java.util.Properties();
-
-    java.util.StringTokenizer urlTokenizer =
-      new java.util.StringTokenizer (url, "/:= \t\n\r\f", true);
-
-    int protocol = tokenizeProtocol (url, urlTokenizer);
-    if (protocol == 0) return null; // unrecognized database URL prefix.
-
-    String slashOrNull = null;
-    if (protocol == DERBY_REMOTE_PROTOCOL) {
-      try {
-        slashOrNull = urlTokenizer.nextToken (":/");
-      }
-      catch (java.util.NoSuchElementException e) {
-        // A null log writer is passed, because jdbc 1 sqlexceptions are automatically traced
-        throw new SqlException (null, e, "Invalid database url syntax: " + url);
-      }
-    }
-      String server = tokenizeServerName (urlTokenizer, url);    // "/server"
-      int port = tokenizeOptionalPortNumber (urlTokenizer, url); // "[:port]/"
-      if (port == 0)
-          port = ClientDataSource.propertyDefault_portNumber;
-
-	  // longDatabase is the databaseName and attributes.  This will be 
-	  // sent to network server as the databaseName
-      String database = tokenizeDatabase (urlTokenizer, url); // "database"
-	 java.util.Properties  augmentedProperties = tokenizeURLProperties (url, properties);
-
-	 
-      int traceLevel;
-      try {
-        traceLevel = ClientDataSource.getTraceLevel (augmentedProperties);
-      }
-      catch (java.lang.NumberFormatException e) {
-        // A null log writer is passed, because jdbc 1 sqlexceptions are automatically traced
-        throw new SqlException (null, e, "trouble reading traceLevel connection property");
-      }
-
-      // Jdbc 1 connections will write driver trace info on a
-      // driver-wide basis using the jdbc 1 driver manager log writer.
-      // This log writer may be narrowed to the connection-level
-      // This log writer will be passed to the agent constructor.
-      org.apache.derby.client.am.LogWriter dncLogWriter =
-        ClientDataSource.computeDncLogWriterForNewConnection (
-          java.sql.DriverManager.getLogWriter(),
-          ClientDataSource.getTraceDirectory (augmentedProperties),
-          ClientDataSource.getTraceFile (augmentedProperties),
-          ClientDataSource.getTraceFileAppend (augmentedProperties),
-          traceLevel,
-          "_driver",
-          traceFileSuffixIndex_++);
-
-      org.apache.derby.client.net.NetConnection conn =
-        new org.apache.derby.client.net.NetConnection (
-          (org.apache.derby.client.net.NetLogWriter) dncLogWriter,
-          java.sql.DriverManager.getLoginTimeout(),
-          server,
-          port,
-          database,
-          augmentedProperties);
-      return conn;
-  }
-
-  public boolean acceptsURL (String url) throws java.sql.SQLException
-  {
-    java.util.StringTokenizer urlTokenizer = new java.util.StringTokenizer (url, "/:=; \t\n\r\f", true);
-    int protocol = tokenizeProtocol (url, urlTokenizer);
-    return protocol != 0;
-  }
-
-  public java.sql.DriverPropertyInfo[] getPropertyInfo (String url,
-                                                        java.util.Properties properties) throws java.sql.SQLException
-  {
-    java.sql.DriverPropertyInfo driverPropertyInfo[] = new java.sql.DriverPropertyInfo[2];
-
-    // If there are no properties set already,
-    // then create a dummy properties just to make the calls go thru.
-    if (properties == null)
-      properties = new java.util.Properties ();
-
-    driverPropertyInfo[0] =
-      new java.sql.DriverPropertyInfo (ClientDataSource.propertyKey_user,
-                                       properties.getProperty (ClientDataSource.propertyKey_user,ClientDataSource.propertyDefault_user));
-
-    driverPropertyInfo[1] =
-      new java.sql.DriverPropertyInfo (ClientDataSource.propertyKey_password,
-                                       properties.getProperty (ClientDataSource.propertyKey_password));
-
-    driverPropertyInfo[0].description =
-      ResourceUtilities.getResource (ResourceKeys.propertyDescription__user);
-    driverPropertyInfo[1].description =
-      ResourceUtilities.getResource (ResourceKeys.propertyDescription__password);
-
-    driverPropertyInfo[0].required = true;
-    driverPropertyInfo[1].required = false; // depending on the security mechanism
-
-    return driverPropertyInfo;
-  }
-
-  public int getMajorVersion()
-  {
-    return Version.getMajorVersion();
-  }
-
-  public int getMinorVersion()
-  {
-    return Version.getMinorVersion();
-  }
-
-  public boolean jdbcCompliant()
-  {
-    return Configuration.jdbcCompliant;
-  }
-
-  // ----------------helper methods---------------------------------------------
-
-  // Tokenize one of the following:
-  //  "jdbc:derby:"
-  // and return 0 if the protcol is unrecognized
-  // return DERBY_PROTOCOL for "jdbc:derby"
-  private static int tokenizeProtocol (String url, java.util.StringTokenizer urlTokenizer) throws SqlException
-  {
-    // Is this condition necessary, StringTokenizer constructor may do this for us
-    if (url == null) return 0;
-
-    if (urlTokenizer == null) return 0;
-
-    try {
-      String jdbc = urlTokenizer.nextToken (":");
-      if (!jdbc.equals ("jdbc")) return 0;
-      if (!urlTokenizer.nextToken (":").equals (":"))
-        return 0; // Skip over the first colon in jdbc:derby:
-      String dbname = urlTokenizer.nextToken (":");
-      int protocol = 0;
-      if (dbname.equals("derby") && (url.indexOf("derby://") != -1)){
-		  // For Derby AS need to check for // since jdbc:derby: is also the
-		  // embedded prefix
-		protocol = DERBY_REMOTE_PROTOCOL;
-      }
-      else
-         return 0;
-
-      if (!urlTokenizer.nextToken (":").equals (":") )
-        return 0; // Skip over the second colon in jdbc:derby:
-
-      return protocol;
-    }
-    catch (java.util.NoSuchElementException e) {
-      return 0;
-    }
-  }
-
-  // tokenize "/server" from URL jdbc:derby://server:port/
-  // returns server name
-  private static String tokenizeServerName (java.util.StringTokenizer urlTokenizer,
-                                                   String url) throws SqlException
-  {
-    try {
-      if (!urlTokenizer.nextToken("/").equals ("/"))
-        // A null log writer is passed, because jdbc 1 sqlexceptions are automatically traced
-        throw new SqlException (null, "Invalid database url syntax: " + url);
-      return urlTokenizer.nextToken ("/:");
-    }
-    catch (java.util.NoSuchElementException e) {
-      // A null log writer is passed, because jdbc 1 sqlexceptions are automatically traced
-      throw new SqlException (null, e, "Invalid database url syntax: " + url);
-    }
-  }
-
-  // tokenize "[:portNumber]/" from URL jdbc:derby://server[:port]/
-  // returns the portNumber or zero if portNumber is not specified.
-  private static int tokenizeOptionalPortNumber (java.util.StringTokenizer urlTokenizer,
-                                                   String url) throws SqlException
-  {
-    try {
-      String firstToken = urlTokenizer.nextToken(":/");
-      if (firstToken.equals (":")) {
-        String port = urlTokenizer.nextToken ("/");
-        if (!urlTokenizer.nextToken ("/").equals ("/")) {
-          // A null log writer is passed, because jdbc 1 sqlexceptions are automatically traced
-          throw new SqlException (null, "Invalid database url syntax: " + url);
-        }
-        return Integer.parseInt (port);
-      }
-      else if (firstToken.equals ("/")) {
-        return 0;
-      }
-      else {
-        // A null log writer is passed, because jdbc 1 sqlexceptions are automatically traced
-        throw new SqlException (null, "Invalid database url syntax: " + url);
-      }
-    }
-    catch (java.util.NoSuchElementException e) {
-      // A null log writer is passed, because jdbc 1 sqlexceptions are automatically traced
-      throw new SqlException (null, e, "Invalid database url syntax: " + url);
-    }
-  }
-
-  //return database name and attributes
-  private static String tokenizeDatabase (java.util.StringTokenizer urlTokenizer,
-                                          String url) throws SqlException
-  {
-    try {
-      String databaseName = urlTokenizer.nextToken (" \t\n\r\f");
-      return databaseName;
-    }
-    catch (java.util.NoSuchElementException e) {
-      // A null log writer is passed, because jdbc 1 sqlexceptions are automatically traced
-      throw new SqlException (null, e, "Invalid database url syntax: " + url);
-    }
-  }
-
-  private static java.util.Properties tokenizeURLProperties (String url,
-                                               java.util.Properties properties)
-	  throws SqlException
-	{
-		String attributeString = null;
-		int attributeIndex = -1;
-		
-		if ((url != null) && 
-			((attributeIndex = url.indexOf(";")) != -1))
-			attributeString = url.substring(attributeIndex);
-		return ClientDataSource.tokenizeAttributes(attributeString, properties);
-	}
- 
 
 }
 

Modified: incubator/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientXADataSource.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientXADataSource.java?rev=165585&r1=165584&r2=165585&view=diff
==============================================================================
--- incubator/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientXADataSource.java (original)
+++ incubator/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientXADataSource.java Sun May  1 23:25:59 2005
@@ -20,44 +20,46 @@
 
 package org.apache.derby.jdbc;
 
-import javax.sql.*;
+import javax.sql.XAConnection;
+import javax.sql.XADataSource;
+
 import org.apache.derby.client.ClientXAConnection;
 
 
 public class ClientXADataSource extends ClientDataSource implements XADataSource,
-                                                                  java.io.Serializable,
-                                                                  javax.naming.Referenceable
-{
-  public static final String className__ = "org.apache.derby.jdbc.ClientXADataSource";
-
-  // following serialVersionUID was generated by the JDK's serialver program
-  // verify it everytime that ClientXADataSource is modified
-  static final long serialVersionUID = 7057075094707674880L;
-
-  private String password = null;
-  synchronized public void setPassword (String password) { this.password = password; }
-  public final static String propertyKey_password = "password";
-
-  public ClientXADataSource()
-  {
-    this.setResultSetHoldability( org.apache.derby.client.ClientBaseDataSource.CLOSE_CURSORS_AT_COMMIT );
-  }
-
-  public XAConnection getXAConnection() throws java.sql.SQLException
-  {
-
-    return getXAConnection(this.user, this.password);
-  }
-
-  public XAConnection getXAConnection (String user, String password) throws java.sql.SQLException
-  {
-    org.apache.derby.client.am.LogWriter dncLogWriter = super.computeDncLogWriterForNewConnection ("_xads");
-
-
-    ClientXAConnection xaConn_ = new ClientXAConnection( this,
-          (org.apache.derby.client.net.NetLogWriter) dncLogWriter,
-          user,
-          password);
-    return xaConn_;
-  }
+        java.io.Serializable,
+        javax.naming.Referenceable {
+    public static final String className__ = "org.apache.derby.jdbc.ClientXADataSource";
+
+    // following serialVersionUID was generated by the JDK's serialver program
+    // verify it everytime that ClientXADataSource is modified
+    static final long serialVersionUID = 7057075094707674880L;
+
+    private String password = null;
+
+    synchronized public void setPassword(String password) {
+        this.password = password;
+    }
+
+    public final static String propertyKey_password = "password";
+
+    public ClientXADataSource() {
+        this.setResultSetHoldability(org.apache.derby.client.ClientBaseDataSource.CLOSE_CURSORS_AT_COMMIT);
+    }
+
+    public XAConnection getXAConnection() throws java.sql.SQLException {
+
+        return getXAConnection(this.user, this.password);
+    }
+
+    public XAConnection getXAConnection(String user, String password) throws java.sql.SQLException {
+        org.apache.derby.client.am.LogWriter dncLogWriter = super.computeDncLogWriterForNewConnection("_xads");
+
+
+        ClientXAConnection xaConn_ = new ClientXAConnection(this,
+                (org.apache.derby.client.net.NetLogWriter) dncLogWriter,
+                user,
+                password);
+        return xaConn_;
+    }
 }