コード例 #1
0
		public void BeginTrasactionTest()
		{			
			BdpConnection conn01 = new BdpConnection(Connection.ConnectionString);
			conn01.Open();
			BdpTransaction txn01 = conn01.BeginTransaction(IsolationLevel.Unspecified);
			txn01.Commit();
			conn01.Close();

			BdpConnection conn02 = new BdpConnection(Connection.ConnectionString);
			conn02.Open();
			BdpTransaction txn02 = conn02.BeginTransaction(IsolationLevel.ReadCommitted);
			txn02.Commit();
			conn02.Close();

			BdpConnection conn03 = new BdpConnection(Connection.ConnectionString);
			conn03.Open();
			BdpTransaction txn03 = conn03.BeginTransaction(IsolationLevel.ReadUncommitted);
			txn03.Commit();
			conn03.Close();

			BdpConnection conn04 = new BdpConnection(Connection.ConnectionString);
			conn04.Open();
			BdpTransaction txn04 = conn04.BeginTransaction(IsolationLevel.RepeatableRead);
			txn04.Commit();
			conn04.Close();
			
			BdpConnection conn05 = new BdpConnection(Connection.ConnectionString);
			conn05.Open();
			BdpTransaction txn05 = conn05.BeginTransaction(IsolationLevel.Serializable);
			txn05.Commit();
			conn05.Close();			
		}
コード例 #2
0
        public void BeginTrasactionTest()
        {
            BdpConnection conn01 = new BdpConnection(Connection.ConnectionString);

            conn01.Open();
            BdpTransaction txn01 = conn01.BeginTransaction(IsolationLevel.Unspecified);

            txn01.Commit();
            conn01.Close();

            BdpConnection conn02 = new BdpConnection(Connection.ConnectionString);

            conn02.Open();
            BdpTransaction txn02 = conn02.BeginTransaction(IsolationLevel.ReadCommitted);

            txn02.Commit();
            conn02.Close();

            BdpConnection conn03 = new BdpConnection(Connection.ConnectionString);

            conn03.Open();
            BdpTransaction txn03 = conn03.BeginTransaction(IsolationLevel.ReadUncommitted);

            txn03.Commit();
            conn03.Close();

            BdpConnection conn04 = new BdpConnection(Connection.ConnectionString);

            conn04.Open();
            BdpTransaction txn04 = conn04.BeginTransaction(IsolationLevel.RepeatableRead);

            txn04.Commit();
            conn04.Close();

            BdpConnection conn05 = new BdpConnection(Connection.ConnectionString);

            conn05.Open();
            BdpTransaction txn05 = conn05.BeginTransaction(IsolationLevel.Serializable);

            txn05.Commit();
            conn05.Close();
        }
コード例 #3
0
ファイル: BaseTest.cs プロジェクト: cafee/NETProvider
		private static void InsertTestData(string connectionString)
		{
			BdpConnection connection = new BdpConnection(connectionString);
			connection.Open();

			StringBuilder commandText = new StringBuilder();

			commandText.Append("DELETE FROM TEST");

			BdpCommand command = new BdpCommand(commandText.ToString(), connection);
			command.ExecuteNonQuery();
			command.Dispose();

			commandText = new StringBuilder();

			commandText.Append("insert into test (int_field, char_field, varchar_field, bigint_field, smallint_field, float_field, double_field, numeric_field, date_field, time_field, timestamp_field, clob_field, blob_field)");
			commandText.Append(" values(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");

			BdpTransaction transaction = connection.BeginTransaction();
			command = new BdpCommand(commandText.ToString(), connection, transaction);

			try
			{
				// Add command parameters
				command.Parameters.Add("@int_field", BdpType.Int32);
				command.Parameters.Add("@char_field", BdpType.String, BdpType.stFixed);
				command.Parameters.Add("@varchar_field", BdpType.String);
				command.Parameters.Add("@bigint_field", BdpType.Int64);
				command.Parameters.Add("@smallint_field", BdpType.Int16);
				command.Parameters.Add("@float_field", BdpType.Float);
				command.Parameters.Add("@double_field", BdpType.Double);
				command.Parameters.Add("@numeric_field", BdpType.Decimal);
				command.Parameters.Add("@date_field", BdpType.Date);
				command.Parameters.Add("@time_Field", BdpType.Time);
				command.Parameters.Add("@timestamp_field", BdpType.DateTime);
				command.Parameters.Add("@clob_field", BdpType.Blob, BdpType.stHMemo);
				command.Parameters.Add("@blob_field", BdpType.Blob, BdpType.stHBinary);

				command.Prepare();

				for (int i = 0; i < 100; i++)
				{
					command.Parameters["@int_field"].Value = i;
					command.Parameters["@char_field"].Value = "IRow " + i.ToString();
					command.Parameters["@varchar_field"].Value = "IRow Number " + i.ToString();
					command.Parameters["@bigint_field"].Value = i;
					command.Parameters["@smallint_field"].Value = i;
					command.Parameters["@float_field"].Value = (float)(i + 10) / 5;
					command.Parameters["@double_field"].Value = Math.Log(i, 10);
					command.Parameters["@numeric_field"].Value = (decimal)(i + 10) / 5;
					command.Parameters["@date_field"].Value = DateTime.Now;
					command.Parameters["@time_field"].Value = DateTime.Now;
					command.Parameters["@timestamp_field"].Value = DateTime.Now;
					command.Parameters["@clob_field"].Value = "IRow Number " + i.ToString();
					command.Parameters["@blob_field"].Value = Encoding.Default.GetBytes("IRow Number " + i.ToString());

					command.ExecuteNonQuery();
				}

				// Commit transaction
				transaction.Commit();
			}
			catch (Exception ex)
			{
				transaction.Rollback();
				throw ex;
			}
			finally
			{
				command.Dispose();
				connection.Close();
			}
		}
コード例 #4
0
        private static void InsertTestData(string connectionString)
        {
            BdpConnection connection = new BdpConnection(connectionString);

            connection.Open();

            StringBuilder commandText = new StringBuilder();

            commandText.Append("DELETE FROM TEST");

            BdpCommand command = new BdpCommand(commandText.ToString(), connection);

            command.ExecuteNonQuery();
            command.Dispose();

            commandText = new StringBuilder();

            commandText.Append("insert into test (int_field, char_field, varchar_field, bigint_field, smallint_field, float_field, double_field, numeric_field, date_field, time_field, timestamp_field, clob_field, blob_field)");
            commandText.Append(" values(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");

            BdpTransaction transaction = connection.BeginTransaction();

            command = new BdpCommand(commandText.ToString(), connection, transaction);

            try
            {
                // Add command parameters
                command.Parameters.Add("@int_field", BdpType.Int32);
                command.Parameters.Add("@char_field", BdpType.String, BdpType.stFixed);
                command.Parameters.Add("@varchar_field", BdpType.String);
                command.Parameters.Add("@bigint_field", BdpType.Int64);
                command.Parameters.Add("@smallint_field", BdpType.Int16);
                command.Parameters.Add("@float_field", BdpType.Float);
                command.Parameters.Add("@double_field", BdpType.Double);
                command.Parameters.Add("@numeric_field", BdpType.Decimal);
                command.Parameters.Add("@date_field", BdpType.Date);
                command.Parameters.Add("@time_Field", BdpType.Time);
                command.Parameters.Add("@timestamp_field", BdpType.DateTime);
                command.Parameters.Add("@clob_field", BdpType.Blob, BdpType.stHMemo);
                command.Parameters.Add("@blob_field", BdpType.Blob, BdpType.stHBinary);

                command.Prepare();

                for (int i = 0; i < 100; i++)
                {
                    command.Parameters["@int_field"].Value       = i;
                    command.Parameters["@char_field"].Value      = "IRow " + i.ToString();
                    command.Parameters["@varchar_field"].Value   = "IRow Number " + i.ToString();
                    command.Parameters["@bigint_field"].Value    = i;
                    command.Parameters["@smallint_field"].Value  = i;
                    command.Parameters["@float_field"].Value     = (float)(i + 10) / 5;
                    command.Parameters["@double_field"].Value    = Math.Log(i, 10);
                    command.Parameters["@numeric_field"].Value   = (decimal)(i + 10) / 5;
                    command.Parameters["@date_field"].Value      = DateTime.Now;
                    command.Parameters["@time_field"].Value      = DateTime.Now;
                    command.Parameters["@timestamp_field"].Value = DateTime.Now;
                    command.Parameters["@clob_field"].Value      = "IRow Number " + i.ToString();
                    command.Parameters["@blob_field"].Value      = Encoding.Default.GetBytes("IRow Number " + i.ToString());

                    command.ExecuteNonQuery();
                }

                // Commit transaction
                transaction.Commit();
            }
            catch (Exception ex)
            {
                transaction.Rollback();
                throw ex;
            }
            finally
            {
                command.Dispose();
                connection.Close();
            }
        }