OracleClientã®ãã°ï¼
OracleClientå¨ãã§3æ¥ããããã£ã¨åµã£ã¦ããã®ã§ãããä»æ¥ããã£ã¨è§£æ±ºãã¾ãããç¾è±¡ããããã¨BCLã®ãã°ã®ãã¼ãªæ°ãããã®ã§ãããã©ã¼ãªãã§ããããï¼
using System; using System.Data; using System.Data.OracleClient; public static class Program { // 以ä¸ã®DDLã§ãã¼ãã«ãä½æãã¦ããã // create table users (name varchar2 (32), age integer); public static void Insert() { using (OracleConnection conn = new OracleConnection("Data Source=orcl;User Id=mei;Password=pass;")) { conn.Open(); OracleCommand cmd = new OracleCommand("INSERT INTO USERS VALUES('mei', 35)", conn); // åé¢ã¬ãã«ã渡ãã¨ï¼åç®ä»¥éããã©ã³ã¶ã¯ã·ã§ã³ãæå¹ã«ãªããªãã // OracleTransaction tx = conn.BeginTransaction(IsolationLevel.ReadCommitted); // âãã®ããã«å¼æ°ç¡ããªãåé¡ãªãã OracleTransaction tx = conn.BeginTransaction(); cmd.Transaction = tx; try { cmd.ExecuteNonQuery(); } finally { // å¿ ããã¼ã«ããã¯ãããã tx.Rollback(); } } } public static void Main(string[] args) { Insert(); Insert(); Insert(); } } /* çµæ ãã¼ã¿ãï¼è¡è¿½å ãããã ã¤ã¾ããæåã®ï¼ä»¶ãããã¼ã«ããã¯ãããªãã */
ã£ã¦ãªæãã§ãã
ãã®ã³ã¼ãã ããªã3æ¥ãæ©ããããªã¢ãã«è¦ãã¾ããããå®éã®ç¾è±¡ã¯Seasar.NETã使ã£ãããã±ã¼ã¸éçºä¸ã«èµ·ããçã対象ã¨ãã¦ã
- èªåã®ã³ã¼ã
- Seasar.NET
- BCL
ãããããã®é çªã«èª¿ã¹ã¦ãã£ãã®ã§æå¾ã®æå¾ã«ãªã£ã¦ãã¾ãã¾ããã(^^;
ãã©ã³ã¶ã¯ã·ã§ã³ã¯ãã¼ã¿ãã¼ã¹å¦çã§ã¯æéè¦é ç®ã¨è¨ã£ã¦è¯ãé¨åã§ããããªã¨ããã§MSããã¹ã£ã¦ããã¨ã¯æããããªãã£ãã®ã§ãããã¡ãã£ã¨ä¿¡ããããªãã¬ãã«ã§ãã°ã£ã¦ããã¦ãã¾ãããããçºè¦ãããªãã¨ããã®ã¯ãMSã®ãã¹ãã±ã¼ã¹ãã¡ãã£ã¨ã¢ã¬ã§ããã.NETã§OracleClientã使ã£ã¦ãã©ã³ã¶ã¯ã·ã§ã³å¦çãã£ã¦ããã¸ã§ãã£ã¦å ¨ç¶ç¡ããã ãªããã¨æç¶ã¨ãªãã¾ãããå¤åãIDEããã®èªåçæã使ã£ã¦æ¥½è¦³çããã¯ã ãã§ãã£ã¦ãããã§ããããã»ã»ã»
ç§ã®è¨æ¶éãããããã¾ãããã.NET2.0ã®é ã¯ä¸è¨ã®ã³ã¼ããåä½ãã¦ããã¨æãã®ã§ã.NET3.0ãããããæ··å
¥ãããã°ãããªããã¨æ³åãã¦ãã¾ãããã¡ããã.NET3.5SP1ã§ãç´ã£ã¦ãã¾ããã.NET3.5SP1ã§çºçãããã°ã¨ããåçãMSãããããã¾ããã
åé¢ã¬ãã«å¨ãã¯éå»ã®è¨äºã§ãIsolationLevel.Serializableãå¹ããªããã¨ãææãã¾ããããOracleClientã®å®è£ ã¯ãããããªæ°ããã¾ããã
(追è¨)
Seasar.NETã¯å¼æ°ããã®BeginTransactionã使ã£ã¦ãã¾ãã®ã§ãOracleClientã使ãã¨å¤§ãã³ãã§ããdiconãã¡ã¤ã«ã§IsolationLevelãæå®ããªãã¦ããSeasarå
é¨ã§ã¯ããã©ã«ãã§ReadCommittedã渡ãã¦ãã¾ã£ã¦ããã®ã§ããªã®ã§ãå¯è½ãªãODP.NETã使ãããSeasar.NETã®ã½ã¼ã¹ã³ã¼ããæ¸ãæãããããªãããã§ãã