コード例 #1
0
        public override void Close()
        {
            ConnectionState orig = State;

            try {
                ClearReferences();
                if (JdbcConnection != null && !JdbcConnection.isClosed())
                {
                    if (!JdbcConnection.getAutoCommit())
                    {
                        JdbcConnection.rollback();
                    }
                    JdbcConnection.close();
                }
            }
            catch (Exception e) {
                // suppress exception
#if DEBUG
                Console.WriteLine("Exception catched at Conection.Close() : {0}\n{1}\n{2}", e.GetType().FullName, e.Message, e.StackTrace);
#endif
            }
            finally {
                JdbcConnection = null;
                lock (_internalStateSync) {
                    _internalState = ConnectionState.Closed;
                }
            }

            ConnectionState current = State;
            if (current != orig)
            {
                OnStateChange(new StateChangeEventArgs(orig, current));
            }
        }
コード例 #2
0
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         try {
             if (JdbcConnection != null && !JdbcConnection.isClosed())
             {
                 JdbcConnection.close();
             }
             JdbcConnection = null;
         }
         catch (java.sql.SQLException exp) {
             throw CreateException(exp);
         }
     }
     base.Dispose(disposing);
 }