internal static void Check(int rc, OracleInternalConnection internalConnection) { if (rc != 0) { throw System.Data.Common.ADP.OracleError(rc, internalConnection); } }
internal static OracleInternalConnection GetPooledConnection( string encryptedConnectionString, OracleConnectionString options, OracleConnection owningObject, out bool isInTransaction) { // If Init() has not been called, call it and set up the cached members if (null == _manager) { Init(); } DBObjectPool pool = null; string userId = null; string poolKey; if (true == options.IntegratedSecurity) { // If using integrated security, find the pool based on the connection string // postpended with the windows identity userId. Otherwise, simply use the // connection string. This will guarantee anyone using integrated security will // always be sent to the appropriate pool. // If this throws, Open will abort. Is there an issue here? UNDONE BUGBUG // Will this fail on some platforms? userId = DBObjectPool.GetCurrentIdentityName(); Debug.Assert(userId != null && userId != "", "OracleConnectionPoolManager: WindowsIdentity.Name returned empty string!"); poolKey = userId + encryptedConnectionString; } else { poolKey = encryptedConnectionString; } pool = _manager.FindPool(poolKey); if (null == pool) { // If we didn't locate a pool, we need to create one. OracleConnectionPoolControl poolControl; poolControl = new OracleConnectionPoolControl(poolKey, options); poolControl.UserId = userId; pool = _manager.FindOrCreatePool(poolControl); } OracleInternalConnection con = (OracleInternalConnection)pool.GetObject(owningObject, out isInTransaction); // If GetObject() failed, the pool timeout occurred. if (con == null) { throw ADP.PooledOpenTimeout(); } return(con); }
internal void CheckError(OciErrorHandle errorHandle, int rc) { switch (((OCI.RETURNCODE)rc)) { case OCI.RETURNCODE.OCI_INVALID_HANDLE: throw System.Data.Common.ADP.InvalidOperation(System.Data.OracleClient.Res.GetString("ADP_InternalError", new object[] { rc })); case OCI.RETURNCODE.OCI_ERROR: case OCI.RETURNCODE.OCI_NO_DATA: { Exception exception2 = System.Data.Common.ADP.OracleError(errorHandle, rc); if ((errorHandle != null) && errorHandle.ConnectionIsBroken) { OracleInternalConnection openInternalConnection = this.GetOpenInternalConnection(); if (openInternalConnection != null) { openInternalConnection.ConnectionIsBroken(); } } throw exception2; } case OCI.RETURNCODE.OCI_SUCCESS_WITH_INFO: { OracleInfoMessageEventArgs infoMessageEvent = new OracleInfoMessageEventArgs(OracleException.CreateException(errorHandle, rc)); this.OnInfoMessage(infoMessageEvent); return; } } if ((rc < 0) || (rc == 0x63)) { throw System.Data.Common.ADP.Simple(System.Data.OracleClient.Res.GetString("ADP_UnexpectedReturnCode", new object[] { rc.ToString(CultureInfo.CurrentCulture) })); } }
internal void Join(OracleInternalConnection internalConnection, Transaction indigoTransaction) { IDtcTransaction oletxTransaction = System.Data.Common.ADP.GetOletxTransaction(indigoTransaction); int rc = TracedNativeMethods.OraMTSJoinTxn(this, oletxTransaction); if (rc != 0) { OracleException.Check(rc, internalConnection); } }
internal void Rollback() { OracleInternalConnection innerConnection = this.InnerConnection as OracleInternalConnection; if (innerConnection != null) { innerConnection.Rollback(); } }
public override void Open() { this.InnerConnection.OpenConnection(this, this.ConnectionFactory); OracleInternalConnection innerConnection = this.InnerConnection as OracleInternalConnection; if (innerConnection != null) { innerConnection.FireDeferredInfoMessageEvents(this); } }
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); } }
public static void ReturnPooledConnection(OracleInternalConnection pooledConnection, OracleConnection owningObject) { pooledConnection.Pool.PutObject(pooledConnection, owningObject); }
public OracleEncoding(OracleInternalConnection connection) { this._connection = connection; }
/// <include file='doc\OracleConnection.uex' path='docs/doc[@for="OracleConnection.Open"]/*' /> private void OpenInternal(OracleConnectionString parsedConnectionString, object transact) { bool isInTransaction; try { try { if (null == parsedConnectionString) { throw ADP.NoConnectionString(); } _state = ConnectionState.Connecting; if (false == parsedConnectionString.Pooling || null != transact) { _internalConnection = new OracleInternalConnection(parsedConnectionString, transact); } else { #if ALLOWTRACING if (ADP._traceObjectPoolActivity) { if (ContextUtil.IsInTransaction) { Debug.WriteLine("Getting Pooled Connection For TransactionId=" + ContextUtil.TransactionId + " ContextId=" + ContextUtil.ContextId); } else { Debug.WriteLine("Getting Pooled Connection without Transaction Context"); } } #endif //ALLOWTRACING _internalConnection = OracleConnectionPoolManager.GetPooledConnection( parsedConnectionString.EncryptedActualConnectionString, parsedConnectionString, this, out isInTransaction ); #if USEORAMTS // Note that we'll only have a non-null transact object when we are manually // enlisted -- automatically enlisted connections take a different path. _internalConnection.ManualEnlistedTransaction = (ITransaction)transact; #endif //USEORAMTS } _hidePassword = true; _state = ConnectionState.Open; _parsedConnectionString = parsedConnectionString; if (UnicodeEnabled) { _encodingDatabase = System.Text.Encoding.Unicode; // for environments initialized in UTF16 mode, we can use straight Unicode } else if (ServerVersionAtLeastOracle8i) { _encodingDatabase = new OracleEncoding(this); // for Oracle8i or greater we'll use Oracle's conversion routines. } else { _encodingDatabase = System.Text.Encoding.Default; // anything prior to Oracle8i doesn't work with Oracle's conversion routines. } _encodingNational = System.Text.Encoding.Unicode; // we use Unicode for the NCHAR/NVARCHAR/NCLOB and let Oracle perform the conversion automatically. } finally { if (ConnectionState.Open != _state) { Cleanup(true, true); } } } catch // Prevent exception filters from running in our space { throw; } }
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); } } }
internal static Exception OracleError(int rc, OracleInternalConnection internalConnection) { return TraceException(OracleException.CreateException(rc, internalConnection)); }