| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146 |
- //
- // TestOracleClient.cs - Tests Sytem.Data.OracleClient
- // data provider in Mono.
- //
- // Part of managed C#/.NET library System.Data.OracleClient.dll
- //
- // Part of the Mono class libraries at
- // mcs/class/System.Data.OracleClient/System.Data.OracleClient.OCI
- //
- // Tests:
- // Assembly: System.Data.OracleClient.dll
- // Namespace: System.Data.OracleClient
- //
- // Author:
- // Daniel Morgan <[email protected]>
- //
- // Copyright (C) Daniel Morgan, 2002
- //
- using System;
- using System.Runtime.InteropServices;
- using System.Data.OracleClient;
- namespace Test.OracleClient
- {
- public class OracleTest
- {
- public OracleTest()
- {
- }
- static void DoTest1(OracleConnection con, int conn)
- {
- string inst = conn.ToString();
- string insertSql =
- "insert into scott.emp " +
- "(empno, ename, job, sal, deptno) " +
- "values(123" + inst + "," +
- "'conn" + inst + "'," +
- "'homy" + inst + "'," +
- "321" + inst + ",20)";
-
- Console.WriteLine("insertSql: " + insertSql);
- OracleCommand cmd = new OracleCommand();
- cmd.Connection = con;
- cmd.CommandText = insertSql;
- cmd.ExecuteNonQuery();
- if(conn == 2)
- cmd.CommandText = "rollback";
- else
- cmd.CommandText = "commit";
- cmd.ExecuteNonQuery();
- }
- static void DoTest9(OracleConnection con) {
- string inst = "9";
- string insertSql =
- "insert into scott.emp " +
- "(empno, ename, job, sal, deptno) " +
- "values(123" + inst + "," +
- "'conn" + inst + "'," +
- "'homy" + inst + "'," +
- "321" + inst + ",20)";
-
- Console.WriteLine("insertSql: " + insertSql);
- OracleCommand cmd = new OracleCommand();
- cmd.Connection = con;
- cmd.CommandText = insertSql;
- cmd.ExecuteNonQuery();
- cmd.CommandText = "commit";
- cmd.ExecuteNonQuery();
- }
- static void ConnectionCount() {
- uint count = OracleConnection.ConnectionCount;
- string msg = "Connection Count: " + count.ToString();
- Console.WriteLine(msg);
- }
- static void Wait(string msg)
- {
- Console.WriteLine(msg);
- Console.WriteLine("Waiting... Presee Enter to continue...");
- string nothing = Console.ReadLine();
- }
- [STAThread]
- static void Main(string[] args)
- {
- string connectionString;
- connectionString =
- "Data Source=dansdb;" +
- "User ID=scott;" +
- "Password=tiger";
- Wait("Verify database.");
- ConnectionCount(); // should be 0
- OracleConnection con1 = new OracleConnection();
- con1.ConnectionString = connectionString;
- con1.Open();
- ConnectionCount(); // should be 1
- OracleConnection con2 = new OracleConnection();
- con2.ConnectionString = connectionString;
- con2.Open();
- ConnectionCount(); // should be 2
- OracleConnection con3 = new OracleConnection();
- con3.ConnectionString = connectionString;
- con3.Open();
- ConnectionCount(); // should be 3
- Wait("Verify Connected.");
-
- DoTest1(con1, 1);
- DoTest1(con2, 2);
- DoTest1(con3, 3);
-
- DoTest9(con1);
- Wait("Verify Proper Results.");
-
- ConnectionCount(); // should be 3
- con1.Close();
- ConnectionCount(); // should be 2
- con2.Close();
- ConnectionCount(); // should be 1
- con3.Close();
- ConnectionCount(); // should be 0
- Wait("Verify Disconnected");
- }
- }
- }
|