Beispiel #1
0
        public static void DemonstrateIsolationLevel(String connString, IsolationLevel level)
        {
            // Before connect the database, recreate the table.
            OperateDatabase.CreateTable(connString);
            DemonstrateIsolationLevel(connString, level, DirtyReadThreads.DirtyReadFirstThread, DirtyReadThreads.DirtyReadSecondThread);
            DisplayData(connString);
            Console.WriteLine();

            OperateDatabase.CreateTable(connString);
            DemonstrateIsolationLevel(connString, level, NonrepeatableReadThreads.NonrepeatableReadFirstThread, NonrepeatableReadThreads.NonrepeatableReadSecondThread);
            Console.WriteLine();

            OperateDatabase.CreateTable(connString);
            DemonstrateIsolationLevel(connString, level, PhantomReadThreads.PhantomReadFirstThread, PhantomReadThreads.PhantomReadSecondThread);
            Console.WriteLine();
        }
Beispiel #2
0
        // Demonstrates the difference between the Serializable and Snapshot transaction
        public static void DemonstrateBetweenSnapshotAndSerializable(String connString)
        {
            OperateDatabase.CreateTable(connString);

            Console.WriteLine("Exchange Vaules in the Snapshot transaction:");
            DemonstrateIsolationLevel(connString, IsolationLevel.Snapshot,
                                      ExchangeValuesThreads.ExchangeValuesFirstThread,
                                      ExchangeValuesThreads.ExchangeValuesSecondThread);
            DisplayData(connString);
            Console.WriteLine();

            Console.WriteLine("Cannot Exchange Vaules in the Serializable transaction:");
            OperateDatabase.CreateTable(connString);
            DemonstrateIsolationLevel(connString, IsolationLevel.Serializable,
                                      ExchangeValuesThreads.ExchangeValuesFirstThread,
                                      ExchangeValuesThreads.ExchangeValuesSecondThread);
            DisplayData(connString);
        }