<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>uprush &#187; 分散トランザクション</title>
	<atom:link href="http://uprush.net/tag/%e5%88%86%e6%95%a3%e3%83%88%e3%83%a9%e3%83%b3%e3%82%b6%e3%82%af%e3%82%b7%e3%83%a7%e3%83%b3/feed/" rel="self" type="application/rss+xml" />
	<link>http://uprush.net</link>
	<description>YiFeng's Blog</description>
	<lastBuildDate>Wed, 03 Feb 2010 14:34:38 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.3</generator>
	<language>ja</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>DotNet 2.0 と SqlServer 2005 による分散トランザクション処理</title>
		<link>http://uprush.net/2009/05/dotnet-20-%e3%81%a8-sqlserver-2005-%e3%81%ab%e3%82%88%e3%82%8b%e5%88%86%e6%95%a3%e3%83%88%e3%83%a9%e3%83%b3%e3%82%b6%e3%82%af%e3%82%b7%e3%83%a7%e3%83%b3%e5%87%a6%e7%90%86/</link>
		<comments>http://uprush.net/2009/05/dotnet-20-%e3%81%a8-sqlserver-2005-%e3%81%ab%e3%82%88%e3%82%8b%e5%88%86%e6%95%a3%e3%83%88%e3%83%a9%e3%83%b3%e3%82%b6%e3%82%af%e3%82%b7%e3%83%a7%e3%83%b3%e5%87%a6%e7%90%86/#comments</comments>
		<pubDate>Sat, 16 May 2009 14:17:59 +0000</pubDate>
		<dc:creator>uprush</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[dotnet]]></category>
		<category><![CDATA[分散トランザクション]]></category>

		<guid isPermaLink="false">http://blog.uprush.net/?p=145</guid>
		<description><![CDATA[
トランザクションの定義

トランザクションとは、データベース テーブルの中の任意のレコードを変更することを指します。レコードの挿入、更新、または削除はトランザクションと呼ばれます。一方、読み出しのためにレ コードを選択する操作は、データベース内に何の変化も生じさせないので、トランザクションではありません。
ビジネス ルールによっては、複数の変更のグループを 1 つのトランザクションとして扱うことが必要となります。例えば、会計ソフトウェアでは、借方と貸方への入力はともに成功するか失敗するかのどちらかでなく てはなりません。借方への入力が成功して貸方への入力が失敗すると、残高がおかしくなります。
この種の、残高を意識しなくてはならない変更は、全体として 1 つのトランザクションを表しています。トランザクションの中でエラーが発生した場合には、トランザクション全体をロールバックしなくてはなりません。
&#160;

分散トランザクションの定義

分散トランザクションには複数のデータベースが関与します。例えば、本部データベースと支店データベース両方のテーブルを一つのトランザクションで 更新し た場合、このトランザクションが分散トランザクションになります。また、分散トランザクションと違う、普通のトランザクションはローカル トランザクションとも呼ばれます。
複数のローカル トランザクションを纏めて一括コミットまたはロールバックする処理もありますが、これは分散トランザクションと違います。複数のコミットまたはロールバックの間、エラーが発生しデータの整合性が取れない可能性がありますから。
&#160;

分散トランザクションにする前

分散トランザクションを適用するには、ＤＢサーバとクライアントの構成が必要となります、セキュリティと運用の利便性を考慮し、分散かローカルか決めます。
ＤＢサーバの構成
　MSDTCのセキュリティ設定を変更します。
クライアントの構成
　MSDTCのセキュリティ設定を変更します、ファイアウォールでMSDTCプログラムとポート135を許可します。
具体的には、www.logistech.co.jp/techtips/msdtc.html を参照します。
参考：support.microsoft.com/kb/839279
&#160;

分散トランザクションの実装

ADO.NET、T/SQL どちらもトランザクションが対応していますが、1 つのデータベースにのみ適用されます。
分散トランザクションの場合、COM+ サービスを使用して管理しなければなりません。従いまして、処理の速度はローカル トランザクションより遅いです。DotNet 2.0 以前、分散トランザクションを適用するためには、System.EnterpriseServices 名前空間を使用しなければなりません。
DotNet 2.0 は System.Transactions を導入し、高パフォーマンスな分散トランザクションを簡単に実装できま。
※以下の参考ソースは説明のための仮ソースであります。
接続文字列
　　分散トランザクションのコネクションの接続文字列は、「Enlist」プロパティを「true」にする必要があります。
　　・ローカル トランザクションの接続文字列 


connectionString&#160;=&#160;&#34;Data&#160;Source=ServerName;Initial&#160;Catalog=DBName;Connect&#160;Timeout=30;MultipleActiveResultSets=true;Enlist=false;User&#160;Id=UserID;PWD=Password&#34;&#160;

connectionString = &#34;Data Source=ServerName;Initial Catalog=DBName;Connect Timeout=30;MultipleActiveResultSets=true;Enlist=false;User Id=UserID;PWD=Password&#34;

&#160;

connectionString = &#34;Data Source=ServerName;Initial Catalog=DBName;Connect Timeout=30;MultipleActiveResultSets=true;Enlist=false;User Id=UserID;PWD=Password&#34;


connectionString = &#34;Data Source=ServerName;Initial Catalog=DBName;Connect Timeout=30;MultipleActiveResultSets=true;Enlist=false;User Id=UserID;PWD=Password&#34;

connectionString = &#34;Data Source=ServerName;Initial Catalog=DBName;Connect Timeout=30;MultipleActiveResultSets=true;Enlist=false;User Id=UserID;PWD=Password&#34;
　　・分散トランザクションの接続文字列     [...]]]></description>
		<wfw:commentRss>http://uprush.net/2009/05/dotnet-20-%e3%81%a8-sqlserver-2005-%e3%81%ab%e3%82%88%e3%82%8b%e5%88%86%e6%95%a3%e3%83%88%e3%83%a9%e3%83%b3%e3%82%b6%e3%82%af%e3%82%b7%e3%83%a7%e3%83%b3%e5%87%a6%e7%90%86/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
