db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From krist...@apache.org
Subject svn commit: r663893 - in /db/derby/code/branches/10.4/java/client/org/apache/derby/client: ClientPooledConnection.java am/Connection.java net/NetConnection.java
Date Fri, 06 Jun 2008 11:03:02 GMT
Author: kristwaa
Date: Fri Jun  6 04:03:01 2008
New Revision: 663893

URL: http://svn.apache.org/viewvc?rev=663893&view=rev
Log:
DERBY-3581: Changing certain properties on client DataSource objects causes existing connections
to reflect the new values.
Backported changes from trunk (10.5):
   648280 (derby-3581-1a-remove_user_password_iteration1.diff) 
   649473 (derby-3581-2a-remove_datasource_iteration1.diff)

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

Modified: db/derby/code/branches/10.4/java/client/org/apache/derby/client/ClientPooledConnection.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.4/java/client/org/apache/derby/client/ClientPooledConnection.java?rev=663893&r1=663892&r2=663893&view=diff
==============================================================================
--- db/derby/code/branches/10.4/java/client/org/apache/derby/client/ClientPooledConnection.java
(original)
+++ db/derby/code/branches/10.4/java/client/org/apache/derby/client/ClientPooledConnection.java
Fri Jun  6 04:03:01 2008
@@ -67,11 +67,6 @@
     /** Resource manager identificator. */
     protected int rmId_ = 0;
 
-    // Cached stuff from constructor
-    private ClientBaseDataSource ds_;
-    private String user_;
-    private String password_;
-
     /**
      * Constructor for non-XA pooled connections.
      * <p>
@@ -90,9 +85,6 @@
                                   String user,
                                   String password) throws SQLException {
         logWriter_ = logWriter;
-        ds_ = ds;
-        user_ = user;
-        password_ = password;
         listeners_ = new ArrayList();
 
         if (ds.maxStatementsToPool() <= 0) {
@@ -145,9 +137,6 @@
                                   String password,
                                   int rmId) throws SQLException {
         logWriter_ = logWriter;
-        ds_ = ds;
-        user_ = user;
-        password_ = password;
         rmId_ = rmId;
         listeners_ = new ArrayList();
 
@@ -244,7 +233,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_, true);
             }
             else {
                 physicalConnection_.lightReset();    //poolfix

Modified: db/derby/code/branches/10.4/java/client/org/apache/derby/client/am/Connection.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.4/java/client/org/apache/derby/client/am/Connection.java?rev=663893&r1=663892&r2=663893&view=diff
==============================================================================
--- db/derby/code/branches/10.4/java/client/org/apache/derby/client/am/Connection.java (original)
+++ db/derby/code/branches/10.4/java/client/org/apache/derby/client/am/Connection.java Fri
Jun  6 04:03:01 2008
@@ -271,22 +271,12 @@
 
     // 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();
-
-
+        if (recomputeFromDataSource) { // no need to reinitialize connection state if ds
hasn't changed
             // property encryptionManager_
             // if needed this will later be initialized by NET calls to initializePublicKeyForEncryption()
             encryptionManager_ = null;
@@ -297,10 +287,6 @@
             currentSchemaName_ = null;
             autoCommit_ = true;
             inUnitOfWork_ = false;
-
-            loginTimeout_ = ds.getLoginTimeout();
-            dataSource_ = ds;
-            
             holdability = ResultSet.HOLD_CURSORS_OVER_COMMIT;
         }
 
@@ -2100,15 +2086,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, 
             boolean recomputeFromDataSource) throws SqlException {
         if (logWriter != null) {
-            logWriter.traceConnectResetEntry(this, logWriter, user, 
-                                            (ds != null) ? ds : dataSource_);
+            logWriter.traceConnectResetEntry(this, logWriter, user_, 
+                                             dataSource_);
         }
         try {
-            reset_(logWriter, user, password, ds, recomputeFromDataSource);
+            reset_(logWriter, recomputeFromDataSource);
         } catch (SqlException sqle) {
             DisconnectException de = new DisconnectException(agent_, 
                 new ClientMessageId(SQLState.CONNECTION_FAILED_ON_RESET));
@@ -2125,8 +2110,7 @@
         availableForReuse_ = false;
     }
 
-    abstract protected void reset_(LogWriter logWriter, String user, 
-            String password, ClientBaseDataSource ds, 
+    abstract protected void reset_(LogWriter logWriter, 
             boolean recomputerFromDataSource) throws SqlException;
 
     /**

Modified: db/derby/code/branches/10.4/java/client/org/apache/derby/client/net/NetConnection.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.4/java/client/org/apache/derby/client/net/NetConnection.java?rev=663893&r1=663892&r2=663893&view=diff
==============================================================================
--- db/derby/code/branches/10.4/java/client/org/apache/derby/client/net/NetConnection.java
(original)
+++ db/derby/code/branches/10.4/java/client/org/apache/derby/client/net/NetConnection.java
Fri Jun  6 04:03:01 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,8 @@
     // 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, recomputeFromDataSource);
         //----------------------------------------------------
         if (recomputeFromDataSource) {
             // do not reset managers on a connection reset.  this information shouldn't
@@ -327,41 +323,26 @@
             sourceSeed_ = null;
             targetSeed_ = null;
             targetSecmec_ = 0;
-            if (ds != null && securityMechanism_ == 0) {
-                securityMechanism_ = ds.getSecurityMechanism(password);
-            }
             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, recomputeFromDataSource);
     }
 
     java.util.List getSpecialRegisters() {



Mime
View raw message