internal static OracleException CreateException(int rc, OracleInternalConnection internalConnection) { using (NativeBuffer buffer = new NativeBuffer_Exception(0x3e8)) { string str; int length = buffer.Length; int dwErr = 0; int num2 = TracedNativeMethods.OraMTSOCIErrGet(ref dwErr, buffer, ref length); if (1 == num2) { str = buffer.PtrToStringAnsi(0, length); } else { str = Res.GetString("ADP_NoMessageAvailable", new object[] { rc, num2 }); dwErr = 0; } if (ConnectionIsBroken(dwErr)) { internalConnection.DoomThisConnection(); } return(new OracleException(str, dwErr)); } }
internal static OracleException CreateException(int rc, OracleInternalConnection internalConnection) { using (NativeBuffer buffer = new NativeBuffer_Exception(0x3e8)) { string str; int length = buffer.Length; int dwErr = 0; int num2 = TracedNativeMethods.OraMTSOCIErrGet(ref dwErr, buffer, ref length); if (1 == num2) { str = buffer.PtrToStringAnsi(0, length); } else { str = Res.GetString("ADP_NoMessageAvailable", new object[] { rc, num2 }); dwErr = 0; } if (ConnectionIsBroken(dwErr)) { internalConnection.DoomThisConnection(); } return new OracleException(str, dwErr); } }
internal void Cleanup(bool disposing, bool silent) { // Cleanup the connection as best we can, releasing as many objects // as we can. We use this when we fail to connect completely, when // we are closing the connection, and when we're disposing of this // object. bool fireEvent = false; _serverTimeZoneAdjustment = TimeSpan.MinValue; // Increment the close counter so the child objects can know when their // connection is toast (or being re-used) Interlocked.Increment(ref _closeCount); // If we're not disposing, it's because we went out of scope, and we're // being garbage collected. We shouldn't touch any managed objects // or bad things can happen. if (disposing) { // We need to "dispose" of the internal connection object, either // by returning it to the pool (if it came from one) or by closing it // outright. if (null != _internalConnection) { if (null == _internalConnection.Pool) { // We just close the connection; there is no need to rollback // here because Oracle will do it for us. _internalConnection.Close(); } else { // Before we return the connection to the pool, we rollback any // active transaction that may have been created. Note that we // don't bother with distributed transactions because we don't // want to them back (it's handled by the TM). We also don't // worry about implicit transactions (like "select...for update") // because we don't want to take the performance hit of the server // round-trip when it isn't very likely. if (TransactionState.LocalStarted == TransState) { // On the off chance that we have some failure during rollback // we just eat it and make sure that the connection is doomed. try { Rollback(); } catch (Exception e) { ADP.TraceException(e); _internalConnection.DoomThisConnection(); } } OracleConnectionPoolManager.ReturnPooledConnection(_internalConnection, this); } _internalConnection = null; } if (null != _scratchBuffer) { _scratchBuffer.Dispose(); _scratchBuffer = null; } // Mark this connection as closed if (_state != ConnectionState.Closed) { _state = ConnectionState.Closed; fireEvent = true; } _encodingDatabase = null; _encodingNational = null; if (fireEvent && !silent) { OnStateChange(ConnectionState.Open, ConnectionState.Closed); } } }