Ejemplo n.º 1
0
        public void Rollback(TestCaseResult result)
        {
            CheckDtcEnabled(result);

            worker.CheckTable(connection, result);
            XAction            x     = new XAction();
            VirtuosoConnection xconn = null;

            try
            {
                string host             = TestSettings.GetString("HOST", "localhost");
                string connectionString = "HOST=" + host + ";UID=dba;PWD=dba;Pooling=True;";
                xconn = x.Connect(connectionString);

                x.DoWork(xconn, worker);
                worker.CheckTable(xconn, result);
                x.Abort();
                worker.DeleteRow(3);
                worker.DeleteRow(4);
                worker.CheckTable(connection, result);
            }
            finally
            {
                if (xconn != null)
                {
                    xconn.Close();
                }
            }
        }
Ejemplo n.º 2
0
        protected override void TearDown()
        {
            DropTable();

            connection.Close();
            connection = null;
        }
Ejemplo n.º 3
0
        public static int add_data(int nrows)
        {
            Object port = AppDomain.CurrentDomain.GetData("OpenLink.Virtuoso.InProcessPort");

            if (port == null)
            {
                throw new Exception("not running as a hosted module");
            }

            VirtuosoConnection c = new VirtuosoConnection("HOST=:in-process:" + port.ToString()
                                                          + ";UID=dummy;PWD=dummy");
            int i;

            c.Open();
            new VirtuosoCommand("exec_result_names (vector ('x'))", c).ExecuteNonQuery();

            VirtuosoCommand cmd = new VirtuosoCommand("result (?)", c);

            cmd.Parameters.Add(":1", SqlDbType.Int);

            for (i = 0; i < nrows; i++)
            {
                cmd.Parameters[":1"].Value = i;
                cmd.ExecuteNonQuery();
            }
            cmd = null;
            c.Close();
            return(0);
        }
Ejemplo n.º 4
0
      public static int add_data (int nrows)
	{
	  Object port = AppDomain.CurrentDomain.GetData("OpenLink.Virtuoso.InProcessPort");

	  if (port == null)
	    throw new Exception ("not running as a hosted module");

	  VirtuosoConnection c = new VirtuosoConnection ("HOST=:in-process:" + port.ToString()
	      + ";UID=dummy;PWD=dummy");
	  int i;

	  c.Open();
          new VirtuosoCommand ("exec_result_names (vector ('x'))", c).ExecuteNonQuery ();
	  
	  VirtuosoCommand cmd = new VirtuosoCommand ("result (?)", c);
	  cmd.Parameters.Add (":1", SqlDbType.Int);

	  for (i = 0; i < nrows; i++)
	    {
	      cmd.Parameters[":1"].Value = i;
	      cmd.ExecuteNonQuery ();
	    }
	  cmd = null;
	  c.Close();
	  return 0;
	}
Ejemplo n.º 5
0
        private VirtuosoCommand CollectInfo()
        {
            if (adapter == null)
            {
                throw new InvalidOperationException("The DataAdapter property is not set.");
            }

            VirtuosoCommand selectCommand = (VirtuosoCommand)adapter.SelectCommand;

            if (selectCommand == null)
            {
                throw new InvalidOperationException("The SelectCommand property is not set.");
            }

            VirtuosoConnection connection = (VirtuosoConnection)selectCommand.Connection;

            if (connection == null)
            {
                throw new InvalidOperationException("The Connection property is not set.");
            }

            if (columns != null)
            {
                return(selectCommand);
            }

            bool close = false;

            if (connection.State == ConnectionState.Closed)
            {
                connection.Open();
                close = true;
            }

            VirtuosoDataReader reader = null;

            try
            {
                reader    = (VirtuosoDataReader)selectCommand.ExecuteReader(CommandBehavior.KeyInfo | CommandBehavior.SchemaOnly);
                tableName = GetTableName(reader.Columns);
                columns   = reader.Columns;
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
                if (close)
                {
                    connection.Close();
                }
            }

            return(selectCommand);
        }
Ejemplo n.º 6
0
        public Object get_var_data(String var, String part, String query, String vars, String xmlnss)
        {
//      Console.WriteLine ("get_var_data:0");
            try
            {
                c.Open();
            }
            catch (Exception e)
            {
//	  Console.WriteLine("{0} Exception caught.", e);
                throw;
            }

//      Console.WriteLine ("get_var_data:1");
            VirtuosoCommand cmd = new VirtuosoCommand("select BPEL.BPEL.get_var_from_dump (?, ?, ?, ?, ?)", c);

//      Console.WriteLine ("get_var_data:2");
            cmd.Parameters.Add(":1", SqlDbType.VarChar);
            cmd.Parameters.Add(":2", SqlDbType.VarChar);
            cmd.Parameters.Add(":3", SqlDbType.VarChar);
            cmd.Parameters.Add(":4", SqlDbType.VarChar);
            cmd.Parameters.Add(":5", SqlDbType.VarChar);
//      Console.WriteLine ("get_var_data:3");

            cmd.Parameters[":1"].Value = var;
            cmd.Parameters[":2"].Value = part;
            cmd.Parameters[":3"].Value = query;
            cmd.Parameters[":4"].Value = vars;
            cmd.Parameters[":5"].Value = xmlnss;

//      Console.WriteLine ("get_var_data:4");
            String result = (String)cmd.ExecuteScalar();

//      Console.WriteLine (result);
//      Console.WriteLine ("get_var_data:7");

            c.Close();
//      Console.WriteLine ("get_var_data:8");

            return(result);
        }
Ejemplo n.º 7
0
        public int Execute(string sparql)
        {
            if (connection.State == System.Data.ConnectionState.Open)
            {
                connection.Close();
            }
            connection.Open();
            var command = connection.CreateCommand();

            //var db = connection.Database;
            command.CommandType = System.Data.CommandType.Text;
            command.CommandText = sparql;
            int val = command.ExecuteNonQuery();

            connection.Close();
            return(val);
        }
Ejemplo n.º 8
0
        public void OdbcConnectionWithoutPooling(TestCaseResult result)
        {
            string             host             = TestSettings.GetString("HOST");
            string             connectionString = "HOST=" + host + ";UID=dba;PWD=dba;Pooling=False;";
            VirtuosoConnection conn             = new VirtuosoConnection(connectionString);

            try
            {
                conn.Open();
                conn.Close();
            }
            finally
            {
                conn.Dispose();
            }
        }
Ejemplo n.º 9
0
        protected virtual void Dispose(bool isDisposing)
        {
            if (_isDisposed)
            {
                return;
            }

            if (isDisposing)
            {
                if (Connection != null)
                {
                    Connection.Close();
                    Connection.Dispose();
                }
            }

            _isDisposed = true;
        }
Ejemplo n.º 10
0
        private static void TestPooling(string connString)
        {
            const int          n = 1000 /*, m = 100*/;
            string             connStringPool = connString + ";Pooling=true";
            string             connStringNoPool = connString + ";Pooling=false";
            VirtuosoConnection first, conn = null;
            DateTime           start;
            int i;

            first = new VirtuosoConnection(connStringNoPool);
            start = DateTime.Now;
            System.Console.WriteLine("before Open(): {0}.{1:000}", DateTime.Now.Second, DateTime.Now.Millisecond);
            first.Open();
            System.Console.WriteLine("after Open(): {0}.{1:000}", DateTime.Now.Second, DateTime.Now.Millisecond);
            System.Console.WriteLine("open first connection {0}", DateTime.Now - start);

            System.Console.WriteLine("With pooling enabled");
            conn  = new VirtuosoConnection(connStringPool);
            start = DateTime.Now;
            for (i = 0; i < n; i++)
            {
                //if ((i % m) == 0)
                //	System.Console.WriteLine ("i={0}", i);
                conn.Open();
                conn.Close();
            }
            System.Console.WriteLine("{0} connections: {1}", n, DateTime.Now - start);

            System.Console.WriteLine("With pooling disabled");
            conn  = new VirtuosoConnection(connStringNoPool);
            start = DateTime.Now;
            for (i = 0; i < n; i++)
            {
                //if ((i % m) == 0)
                //	System.Console.WriteLine ("i={0}", i);
                conn.Open();
                conn.Close();
            }
            System.Console.WriteLine("{0} connections: {1}", n, DateTime.Now - start);

            start = DateTime.Now;
            first.Close();
            System.Console.WriteLine("close first connection {0}", DateTime.Now - start);
        }
Ejemplo n.º 11
0
        public void State(TestCaseResult result)
        {
            string             host             = TestSettings.GetString("HOST");
            string             connectionString = "HOST=" + host + ";UID=dba;PWD=dba;";
            VirtuosoConnection conn             = new VirtuosoConnection(connectionString);

            try
            {
                result.FailIfNotEqual(ConnectionState.Closed, conn.State);
                conn.Open();
                result.FailIfNotEqual(ConnectionState.Open, conn.State);
                conn.Close();
                result.FailIfNotEqual(ConnectionState.Closed, conn.State);
            }
            finally
            {
                conn.Dispose();
            }
        }
Ejemplo n.º 12
0
        public void PersistSecurityInfo(TestCaseResult result)
        {
            string             host             = TestSettings.GetString("HOST");
            string             connectionString = "HOST=" + host + ";UID=dba;PWD=dba;Persist Security Info=true;";
            VirtuosoConnection conn             = new VirtuosoConnection(connectionString);

            try
            {
                result.FailIfNotEqual(connectionString, conn.ConnectionString);
                conn.Open();
                result.FailIfNotEqual(connectionString, conn.ConnectionString);
                conn.Close();
                result.FailIfNotEqual(connectionString, conn.ConnectionString);
            }
            finally
            {
                conn.Dispose();
            }
        }
Ejemplo n.º 13
0
        public void Close()
#endif
        {
            Debug.WriteLineIf(CLI.FnTrace.Enabled, "VirtuosoDataReader.Close()");
            if (open)
            {
                if (command != null)
                {
                    command.CloseDataReader();
                    command = null;
                }
                if (connection != null && (commandBehavior & CommandBehavior.CloseConnection) != 0)
                {
                    connection.Close();
                    connection = null;
                }
                columns = null;
                open    = false;
            }
        }
Ejemplo n.º 14
0
		private static void TestPooling (string connString)
		{
			const int n = 1000/*, m = 100*/;
			string connStringPool = connString + ";Pooling=true";
			string connStringNoPool = connString + ";Pooling=false";
			VirtuosoConnection first, conn = null;
			DateTime start;
			int i;

			first = new VirtuosoConnection (connStringNoPool);
			start = DateTime.Now;
			System.Console.WriteLine ("before Open(): {0}.{1:000}", DateTime.Now.Second, DateTime.Now.Millisecond);
			first.Open ();
			System.Console.WriteLine ("after Open(): {0}.{1:000}", DateTime.Now.Second, DateTime.Now.Millisecond);
			System.Console.WriteLine ("open first connection {0}", DateTime.Now - start);

			System.Console.WriteLine ("With pooling enabled");
			conn = new VirtuosoConnection (connStringPool);
			start = DateTime.Now;
			for (i = 0; i < n; i++)
			{
				//if ((i % m) == 0)
				//	System.Console.WriteLine ("i={0}", i);
				conn.Open ();
				conn.Close ();
			}
			System.Console.WriteLine ("{0} connections: {1}", n, DateTime.Now - start);

			System.Console.WriteLine ("With pooling disabled");
			conn = new VirtuosoConnection (connStringNoPool);
			start = DateTime.Now;
			for (i = 0; i < n; i++)
			{
				//if ((i % m) == 0)
				//	System.Console.WriteLine ("i={0}", i);
				conn.Open ();
				conn.Close ();
			}
			System.Console.WriteLine ("{0} connections: {1}", n, DateTime.Now - start);

			start = DateTime.Now;
			first.Close ();
			System.Console.WriteLine ("close first connection {0}", DateTime.Now - start);
		}
Ejemplo n.º 15
0
 public void Dispose()
 {
     Connection.Close();
     Connection.Dispose();
 }