public void Remove(ConnectionHolder connection) { if (connection != null) { List.Remove(connection); } }
public void AddConnection(ConnectionAlias alias, bool persistent) { OdbcConnection newConnection; for (int i = 0; i < ConnectionPool.Count; i++) { if (alias.CompareToConnection(ConnectionPool[i].Connection)) { // This connection already exists if (ConnectionPool[i].Status == ConnectionHolderStatus.Active) { // This connection is currently in use by another object // So create an identical connection instead } } } newConnection = new OdbcConnection(alias.GetConnectionString()); try { newConnection.Open(); if (!persistent) { newConnection.Close(); } } catch (Exception err) { LoggingHelper.Log("Error in ConnectionHandler.AddConnection", LogSeverity.Error, err, false); throw new Exception("The connection test for the newly added connection failed.", err); } // Connection test succeeded ConnectionHolder newConnHold = new ConnectionHolder(newConnection, null); newConnHold.PersistentConnection = persistent; ConnectionPool.Add(newConnHold); }
public ConnectionHolder AddConnection(ConnectionAlias alias) { OdbcConnection newConnection; /* * for (int i = 0;i < ConnectionPool.Count;i++) * { * if (alias.CompareToConnection(ConnectionPool[i].Connection)) * { * // This connection already exists * if (ConnectionPool[i].Status == ConnectionHolderStatus.Active) * { * // This connection is currently in use by another object * // So create an identical connection instead * } * } * } */ newConnection = new OdbcConnection(alias.GetConnectionString()); try { newConnection.Open(); } catch (Exception err) { LoggingHelper.Log("Error in ConnectionHandler.AddConnection", LogSeverity.Error, err, false); throw new Exception("The connection test for the newly added connection failed.", err); } // Connection test succeeded ConnectionHolder newConnHold = new ConnectionHolder(newConnection, null); ConnectionPool.Add(newConnHold); return(newConnHold); }
public void Add(ConnectionHolder connection) { List.Add(connection); }