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/05 19:00:09 UTC

svn commit: r168355 - in /incubator/derby/code/trunk/java/client/org/apache/derby: client/ClientBaseDataSource.java jdbc/ClientConnectionPoolDataSource.java jdbc/ClientDataSource.java jdbc/ClientXADataSource.java

Author: jboynes
Date: Thu May  5 10:00:08 2005
New Revision: 168355

URL: http://svn.apache.org/viewcvs?rev=168355&view=rev
Log:
move all generic implementation into ClientBaseDataSource

Modified:
    incubator/derby/code/trunk/java/client/org/apache/derby/client/ClientBaseDataSource.java
    incubator/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientConnectionPoolDataSource.java
    incubator/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientDataSource.java
    incubator/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientXADataSource.java

Modified: incubator/derby/code/trunk/java/client/org/apache/derby/client/ClientBaseDataSource.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/client/org/apache/derby/client/ClientBaseDataSource.java?rev=168355&r1=168354&r2=168355&view=diff
==============================================================================
--- incubator/derby/code/trunk/java/client/org/apache/derby/client/ClientBaseDataSource.java (original)
+++ incubator/derby/code/trunk/java/client/org/apache/derby/client/ClientBaseDataSource.java Thu May  5 10:00:08 2005
@@ -248,21 +248,6 @@
         return parseBoolean(retrieveMessageTextString, propertyDefault_retrieveMessageText);
     }
 
-    // ---------------------------- traceLevel -----------------------------------
-    //
-
-    public final static int TRACE_NONE = 0x0;
-    public final static int TRACE_ALL = 0xFFFFFFFF;
-    public final static int propertyDefault_traceLevel = TRACE_ALL;
-    public final static String propertyKey_traceLevel = "traceLevel";
-
-    protected int traceLevel = propertyDefault_traceLevel;
-
-    public static int getTraceLevel(Properties properties) {
-        String traceLevelString = properties.getProperty(propertyKey_traceLevel);
-        return parseInt(traceLevelString, propertyDefault_traceLevel);
-    }
-
     // ---------------------------- traceFile -----------------------------------
     //
     protected String traceFile = null;
@@ -305,6 +290,12 @@
         return properties.getProperty("password");
     }
 
+    protected String password = null;
+
+    synchronized public void setPassword(String password) {
+        this.password = password;
+    }
+
     //------------------------ interface methods ---------------------------------
 
     public Reference getReference() throws NamingException {
@@ -703,6 +694,217 @@
         throw new SqlException(null, "JDBC attribute " + attribute +
                 "has an invalid value " + value +
                 " Valid values are " + choicesStr);
+    }
+
+    /*
+     * 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) NetConfiguration.SECMEC_USRIDONL;
+    public final static short CLEAR_TEXT_PASSWORD_SECURITY = (short) NetConfiguration.SECMEC_USRIDPWD;
+    public final static short ENCRYPTED_PASSWORD_SECURITY = (short) NetConfiguration.SECMEC_USRENCPWD;
+    public final static short ENCRYPTED_USER_AND_PASSWORD_SECURITY = (short) NetConfiguration.SECMEC_EUSRIDPWD;
+
+    synchronized public void setSecurityMechanism(short securityMechanism) {
+        this.securityMechanism = securityMechanism;
+    }
+
+    public short getSecurityMechanism() {
+        return getUpgradedSecurityMechanism(securityMechanism, 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;
+    }
+
+
+    // ---------------------------- traceLevel -----------------------------------
+    //
+
+    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;
+
+    public final static int propertyDefault_traceLevel = TRACE_ALL;
+    public final static String propertyKey_traceLevel = "traceLevel";
+
+    protected int traceLevel = propertyDefault_traceLevel;
+
+    public static int getTraceLevel(Properties properties) {
+        String traceLevelString = properties.getProperty(propertyKey_traceLevel);
+        return parseInt(traceLevelString, propertyDefault_traceLevel);
+    }
+
+    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.
+     */
+    protected void updateDataSourceValues(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/ClientConnectionPoolDataSource.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientConnectionPoolDataSource.java?rev=168355&r1=168354&r2=168355&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 Thu May  5 10:00:08 2005
@@ -35,14 +35,6 @@
     private 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";
-
     public ClientConnectionPoolDataSource() {
         super();
     }

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=168355&r1=168354&r2=168355&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 Thu May  5 10:00:08 2005
@@ -22,12 +22,10 @@
 
 import java.sql.Connection;
 import java.sql.SQLException;
-import java.util.Properties;
 import javax.sql.DataSource;
 
 import org.apache.derby.client.ClientBaseDataSource;
 import org.apache.derby.client.am.LogWriter;
-import org.apache.derby.client.net.NetConfiguration;
 import org.apache.derby.client.net.NetConnection;
 import org.apache.derby.client.net.NetLogWriter;
 
@@ -112,12 +110,6 @@
     // 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.
@@ -163,204 +155,6 @@
         LogWriter dncLogWriter = super.computeDncLogWriterForNewConnection("_sds");
         updateDataSourceValues(tokenizeAttributes(connectionAttributes, null));
         return new NetConnection((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) NetConfiguration.SECMEC_USRIDONL;
-    public final static short CLEAR_TEXT_PASSWORD_SECURITY = (short) NetConfiguration.SECMEC_USRIDPWD;
-    public final static short ENCRYPTED_PASSWORD_SECURITY = (short) NetConfiguration.SECMEC_USRENCPWD;
-    public final static short ENCRYPTED_USER_AND_PASSWORD_SECURITY = (short) NetConfiguration.SECMEC_EUSRIDPWD;
-
-    synchronized public void setSecurityMechanism(short securityMechanism) {
-        this.securityMechanism = securityMechanism;
-    }
-
-    public short getSecurityMechanism() {
-        return getUpgradedSecurityMechanism(securityMechanism, 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(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/ClientXADataSource.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientXADataSource.java?rev=168355&r1=168354&r2=168355&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 Thu May  5 10:00:08 2005
@@ -35,14 +35,6 @@
     // verify it everytime that ClientXADataSource is modified
     private 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(CLOSE_CURSORS_AT_COMMIT);
     }