db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From krist...@apache.org
Subject svn commit: r648280 - in /db/derby/code/trunk/java/client/org/apache/derby/client: ClientPooledConnection.java am/Connection.java net/NetConnection.java
Date Tue, 15 Apr 2008 15:18:04 GMT
Author: kristwaa
Date: Tue Apr 15 08:18:00 2008
New Revision: 648280

URL: http://svn.apache.org/viewvc?rev=648280&view=rev
Log:
DERBY-3581 (partial): Changing certain properties on client DataSource objects causes existing
connections to reflect the new values.
First iteration of code removal / refactoring.
Patch file: derby-3581-1a-remove_user_password_iteration1.diff

Modified:
    db/derby/code/trunk/java/client/org/apache/derby/client/ClientPooledConnection.java
    db/derby/code/trunk/java/client/org/apache/derby/client/am/Connection.java
    db/derby/code/trunk/java/client/org/apache/derby/client/net/NetConnection.java

Modified: db/derby/code/trunk/java/client/org/apache/derby/client/ClientPooledConnection.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/ClientPooledConnection.java?rev=648280&r1=648279&r2=648280&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/ClientPooledConnection.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/ClientPooledConnection.java Tue
Apr 15 08:18:00 2008
@@ -69,8 +69,6 @@
 
     // Cached stuff from constructor
     private ClientBaseDataSource ds_;
-    private String user_;
-    private String password_;
 
     /**
      * Constructor for non-XA pooled connections.
@@ -91,8 +89,6 @@
                                   String password) throws SQLException {
         logWriter_ = logWriter;
         ds_ = ds;
-        user_ = user;
-        password_ = password;
         listeners_ = new ArrayList();
 
         if (ds.maxStatementsToPool() <= 0) {
@@ -146,8 +142,6 @@
                                   int rmId) throws SQLException {
         logWriter_ = logWriter;
         ds_ = ds;
-        user_ = user;
-        password_ = password;
         rmId_ = rmId;
         listeners_ = new ArrayList();
 
@@ -244,7 +238,7 @@
             	// to reset the connection state to the default on 
             	// PooledConnection.getConnection() otherwise the 
             	// isolation level and holdability was not correct and out of sync with the
server.
-                physicalConnection_.reset(logWriter_, user_, password_, ds_, true);
+                physicalConnection_.reset(logWriter_, ds_, true);
             }
             else {
                 physicalConnection_.lightReset();    //poolfix

Modified: db/derby/code/trunk/java/client/org/apache/derby/client/am/Connection.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/am/Connection.java?rev=648280&r1=648279&r2=648280&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/am/Connection.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/am/Connection.java Tue Apr 15
08:18:00 2008
@@ -271,19 +271,13 @@
 
     // This is a callback method, called by subsystem - NetConnection
     protected void resetConnection(LogWriter logWriter,
-                                   String user,
                                    ClientBaseDataSource ds,
                                    boolean recomputeFromDataSource) throws SqlException {
         // Transaction isolation level is handled in completeReset.
         // clearWarningsX() will re-initialize the following properties
         clearWarningsX();
 
-        user_ = (user != null) ? user : user_;
-
         if (ds != null && recomputeFromDataSource) { // no need to reinitialize connection
state if ds hasn't changed
-            user_ = (user != null) ? user : ds.getUser();
-            ;
-
             retrieveMessageText_ = ds.getRetrieveMessageText();
 
 
@@ -2100,15 +2094,14 @@
     // can this be called in a unit of work
     // can this be called from within a stored procedure
     //
-    synchronized public void reset(LogWriter logWriter, String user, 
-            String password, ClientBaseDataSource ds, 
+    synchronized public void reset(LogWriter logWriter, ClientBaseDataSource ds, 
             boolean recomputeFromDataSource) throws SqlException {
         if (logWriter != null) {
-            logWriter.traceConnectResetEntry(this, logWriter, user, 
+            logWriter.traceConnectResetEntry(this, logWriter, user_, 
                                             (ds != null) ? ds : dataSource_);
         }
         try {
-            reset_(logWriter, user, password, ds, recomputeFromDataSource);
+            reset_(logWriter, ds, recomputeFromDataSource);
         } catch (SqlException sqle) {
             DisconnectException de = new DisconnectException(agent_, 
                 new ClientMessageId(SQLState.CONNECTION_FAILED_ON_RESET));
@@ -2125,8 +2118,7 @@
         availableForReuse_ = false;
     }
 
-    abstract protected void reset_(LogWriter logWriter, String user, 
-            String password, ClientBaseDataSource ds, 
+    abstract protected void reset_(LogWriter logWriter, ClientBaseDataSource ds, 
             boolean recomputerFromDataSource) throws SqlException;
 
     /**

Modified: db/derby/code/trunk/java/client/org/apache/derby/client/net/NetConnection.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/net/NetConnection.java?rev=648280&r1=648279&r2=648280&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/net/NetConnection.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/net/NetConnection.java Tue Apr
15 08:18:00 2008
@@ -232,7 +232,7 @@
         this.pooledConnection_ = null;
         this.closeStatementsOnClose = true;
         netAgent_ = (NetAgent) super.agent_;
-        initialize(user, password, dataSource, rmId, isXAConn);
+        initialize(password, dataSource, rmId, isXAConn);
     }
 
     public NetConnection(NetLogWriter netLogWriter,
@@ -283,13 +283,12 @@
                          ClientPooledConnection cpc) throws SqlException {
         super(netLogWriter, user, password, isXAConn, dataSource);
         netAgent_ = (NetAgent) super.agent_;
-        initialize(user, password, dataSource, rmId, isXAConn);
+        initialize(password, dataSource, rmId, isXAConn);
         this.pooledConnection_=cpc;
         this.closeStatementsOnClose = !cpc.isStatementPoolingEnabled();
     }
 
-    private void initialize(String user,
-                            String password,
+    private void initialize(String password,
                             org.apache.derby.jdbc.ClientBaseDataSource dataSource,
                             int rmId,
                             boolean isXAConn) throws SqlException {
@@ -308,11 +307,9 @@
     // preferably without password in the method signature.
     // We can probally get rid of flowReconnect method.
     public void resetNetConnection(org.apache.derby.client.am.LogWriter logWriter,
-                                   String user,
-                                   String password,
                                    org.apache.derby.jdbc.ClientBaseDataSource ds,
                                    boolean recomputeFromDataSource) throws SqlException {
-        super.resetConnection(logWriter, user, ds, recomputeFromDataSource);
+        super.resetConnection(logWriter, ds, recomputeFromDataSource);
         //----------------------------------------------------
         if (recomputeFromDataSource) {
             // do not reset managers on a connection reset.  this information shouldn't
@@ -328,40 +325,30 @@
             targetSeed_ = null;
             targetSecmec_ = 0;
             if (ds != null && securityMechanism_ == 0) {
-                securityMechanism_ = ds.getSecurityMechanism(password);
+                securityMechanism_ =
+                        ds.getSecurityMechanism(getDeferredResetPassword());
             }
             resetConnectionAtFirstSql_ = false;
 
         }
-        if (password != null) {
-            deferredResetPassword_ = null;
-        } else {
-            password = getDeferredResetPassword();
-        }
         // properties prddta_ and crrtkn_ will be initialized by
         // calls to constructPrddta() and constructCrrtkn()
         //----------------------------------------------------------
-        boolean isDeferredReset = flowReconnect(password, securityMechanism_);
+        boolean isDeferredReset = flowReconnect(getDeferredResetPassword(),
+                                                securityMechanism_);
         completeReset(isDeferredReset, recomputeFromDataSource);
     }
 
 
     protected void reset_(org.apache.derby.client.am.LogWriter logWriter,
-                          String user, String password,
                           ClientBaseDataSource ds,
                           boolean recomputeFromDataSource) throws SqlException {
-        checkResetPreconditions(logWriter, user, password, ds);
-        resetNetConnection(logWriter, user, password, ds, recomputeFromDataSource);
-    }
-
-    protected void checkResetPreconditions(org.apache.derby.client.am.LogWriter logWriter,
-                                           String user,
-                                           String password,
-                                           ClientBaseDataSource ds) throws SqlException {
         if (inUnitOfWork_) {
             throw new SqlException(logWriter, 
-                new ClientMessageId(SQLState.NET_CONNECTION_RESET_NOT_ALLOWED_IN_UNIT_OF_WORK));
+                new ClientMessageId(
+                    SQLState.NET_CONNECTION_RESET_NOT_ALLOWED_IN_UNIT_OF_WORK));
         }
+        resetNetConnection(logWriter, ds, recomputeFromDataSource);
     }
 
     java.util.List getSpecialRegisters() {



Mime
View raw message