コード例 #1
0
        public void findByValue()
        {
            EsgynDBParameter  p1   = new EsgynDBParameter("param-1", "abc");
            EsgynDBParameter  p2   = new EsgynDBParameter("param-2", "def");
            EsgynDBParameter  p3   = new EsgynDBParameter("param-3", "ghi");
            EsgynDBParameter  p4   = new EsgynDBParameter("param-4", "jkl");
            EsgynDBParameter  p5   = new EsgynDBParameter("param-5", "mno");
            EsgynDBConnection conn = new EsgynDBConnection();

            conn.ConnectionString = ConnectionString;
            conn.Open();
            EsgynDBCommand             cmd  = conn.CreateCommand();
            EsgynDBParameterCollection list = cmd.Parameters;

            list.Add(p1);
            list.Add(p2);
            list.Add(p3);
            list.Add(p4);
            list.Add(p5);

            EsgynDBParameter test = new EsgynDBParameter("param-test", "jkl");

            Assert.IsTrue(list.Contains(test));
            Assert.IsFalse(list.Contains("aaa"));
        }
コード例 #2
0
        public void TestBatchLoad()
        {
            EsgynDBConnection conn = new EsgynDBConnection();

            conn.ConnectionString = ConnectionString;
            conn.Open();

            EsgynDBCommand cmd = conn.CreateCommand();

            prepareTable(cmd);

            //start loading...
            log.Info("Start loading...");
            cmd.CommandText = "upsert using load into t0 values(?,?)";
            cmd.Parameters.Add(new EsgynDBParameter("c0", EsgynDBType.Varchar));
            cmd.Parameters.Add(new EsgynDBParameter("c1", EsgynDBType.Varchar));

            log.Info("Prepare the insertion sql");
            cmd.Prepare();

            log.Info("Put rows into batch");
            for (int i = 0; i < 10; i++)
            {
                cmd.Parameters[0].Value = "test col-" + i;
                cmd.Parameters[1].Value = "test col " + (i * 2 + 1);
                cmd.AddBatch();
            }

            log.Info("Execute batch");
            cmd.ExecuteNonQuery();

            //Check all inserted data
            log.Info("Check all inserted data");
            cmd.Parameters.Clear();
            cmd.CommandText = "select * from t0";
            EsgynDBDataReader dr = cmd.ExecuteReader();

            while (dr.Read())
            {
                for (int i = 0; i < dr.FieldCount; i++)
                {
                    log.Info(dr.GetValue(i) + " " + dr.GetDataTypeName(i));
                }
            }
        }
コード例 #3
0
        public void setCQDs()
        {
            using (EsgynDBConnection conn = new EsgynDBConnection())
            {
                conn.ConnectionString = ConnectionString;
                conn.Open();
                EsgynDBCommand cmd = conn.CreateCommand();
                log.Info("ESP_INACTIVE_TIMEOUT '66666'");
                cmd.CommandText = "SET SESSION DEFAULT ESP_INACTIVE_TIMEOUT '666666'";
                cmd.ExecuteNonQuery();
                log.Info("ESP_IDLE_TIMEOUT '77777'");
                cmd.CommandText = "SET SESSION DEFAULT ESP_IDLE_TIMEOUT '666666'";
                cmd.ExecuteNonQuery();
                log.Info("SHOWCONTROL_SHOW_ALL 'on'!");
                cmd.CommandText = "CONTROL QUERY DEFAULT SHOWCONTROL_SHOW_ALL 'on'";
                cmd.ExecuteNonQuery();

                log.Info("SHOWCONTROL ALL!");
                cmd.CommandText = "SHOWCONTROL ALL";
                EsgynDBDataReader ca = cmd.ExecuteReader();
                bool flag            = false;
                while (ca.Read())
                {
                    if (!flag)
                    {
                        flag = true;
                    }
                    log.Info(ca.GetValue(0) + "");
                }
                log.Info("Done!");

                /*
                 *
                 * Continue to do whatever you want...
                 *
                 */

                Assert.IsTrue(flag, "No data in query 'SHOWCONTROL ALL'");
            }
        }
コード例 #4
0
ファイル: DBParameterTest.cs プロジェクト: kevinxu021/sample
        public void findByValue()
        {
            EsgynDBParameter p1 = new EsgynDBParameter("param-1","abc");
            EsgynDBParameter p2 = new EsgynDBParameter("param-2", "def");
            EsgynDBParameter p3 = new EsgynDBParameter("param-3", "ghi");
            EsgynDBParameter p4 = new EsgynDBParameter("param-4", "jkl");
            EsgynDBParameter p5 = new EsgynDBParameter("param-5", "mno");
            EsgynDBConnection conn = new EsgynDBConnection();
            conn.ConnectionString = ConnectionString;
            conn.Open();
            EsgynDBCommand cmd = conn.CreateCommand();
            EsgynDBParameterCollection list = cmd.Parameters;
            list.Add(p1);
            list.Add(p2);
            list.Add(p3);
            list.Add(p4);
            list.Add(p5);

            EsgynDBParameter test = new EsgynDBParameter("param-test", "jkl");
            Assert.IsTrue(list.Contains(test));
            Assert.IsFalse(list.Contains("aaa"));
        }
コード例 #5
0
ファイル: CQDSamples.cs プロジェクト: kevinxu021/sample
        public void setCQDs()
        {
            using (EsgynDBConnection conn = new EsgynDBConnection())
                {
                    conn.ConnectionString = ConnectionString;
                    conn.Open();
                    EsgynDBCommand cmd = conn.CreateCommand();
                    log.Info("ESP_INACTIVE_TIMEOUT '66666'");
                    cmd.CommandText = "SET SESSION DEFAULT ESP_INACTIVE_TIMEOUT '666666'";
                    cmd.ExecuteNonQuery();
                    log.Info("ESP_IDLE_TIMEOUT '77777'");
                    cmd.CommandText = "SET SESSION DEFAULT ESP_IDLE_TIMEOUT '666666'";
                    cmd.ExecuteNonQuery();
                    log.Info("SHOWCONTROL_SHOW_ALL 'on'!");
                    cmd.CommandText = "CONTROL QUERY DEFAULT SHOWCONTROL_SHOW_ALL 'on'";
                    cmd.ExecuteNonQuery();

                    log.Info("SHOWCONTROL ALL!");
                    cmd.CommandText = "SHOWCONTROL ALL";
                    EsgynDBDataReader ca = cmd.ExecuteReader();
                    bool flag = false;
                    while (ca.Read())
                    {
                        if(!flag)
                            flag = true;
                        log.Info(ca.GetValue(0) +"");
                    }
                    log.Info("Done!");

                    /*
                     *
                     *Continue to do whatever you want...
                     *
                     */

                    Assert.IsTrue(flag, "No data in query 'SHOWCONTROL ALL'");
            }
        }
コード例 #6
0
        public void TestBatch()
        {
            try
            {
                using (EsgynDBConnection conn = new EsgynDBConnection())
                {
                    conn.ConnectionString = ConnectionString;
                    conn.Open();

                    using (EsgynDBCommand cmd = conn.CreateCommand())
                    {
                        try
                        {
                            cmd.CommandText = "drop table t0";
                            cmd.ExecuteNonQuery();
                        }
                        catch (Exception e)
                        {
                            log.Warn(e.Message);
                        }

                        cmd.CommandText = "create table t0 (c1 varchar(20), c2 nchar(20)) no partition";
                        cmd.ExecuteNonQuery();

                        cmd.CommandText = "insert into t0 values(?,?)";
                        cmd.Parameters.Add(new EsgynDBParameter("c0", EsgynDBType.Varchar));
                        cmd.Parameters.Add(new EsgynDBParameter("c1", EsgynDBType.Varchar));

                        cmd.Prepare();

                        for (int i = 0; i < 10; i++)
                        {
                            if (i == 2)
                            {
                                cmd.Parameters[0].Value = "test col1";
                            }
                            else
                            {
                                cmd.Parameters[0].Value = "test col1rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr";
                            }
                            cmd.Parameters[1].Value = "test col2";
                            cmd.AddBatch();
                            log.Info(cmd.Parameters[0].Value);
                        }

                        //cmd.ExecuteNonQuery();
                        //Console.Read();

                        cmd.ExecuteNonQuery();

                        log.Info("start to select ....");
                        cmd.Parameters.Clear();
                        cmd.CommandText = "select * from t0";
                        using (EsgynDBDataReader dr = cmd.ExecuteReader())
                        {
                            while (dr.Read())
                            {
                                for (int i = 0; i < dr.FieldCount; i++)
                                {
                                    log.Info(dr.GetValue(i) + " " + dr.GetDataTypeName(i));
                                }
                            }
                        }
                    }
                }
            }
            catch (EsgynDBException e)
            {
                log.Info(e.ToString());
                for (int i = 0; i < e.Errors.Count; i++)
                {
                    log.Info(e.Errors[i]);
                }
            }
        }
コード例 #7
0
        public void TestBatchLoad()
        {
            EsgynDBConnection conn = new EsgynDBConnection();
            conn.ConnectionString = ConnectionString;
            conn.Open();

            EsgynDBCommand cmd = conn.CreateCommand();
            prepareTable(cmd);

            //start loading...
            log.Info("Start loading...");
            cmd.CommandText = "upsert using load into t0 values(?,?)";
            cmd.Parameters.Add(new EsgynDBParameter("c0", EsgynDBType.Varchar));
            cmd.Parameters.Add(new EsgynDBParameter("c1", EsgynDBType.Varchar));

            log.Info("Prepare the insertion sql");
            cmd.Prepare();

            log.Info("Put rows into batch");
            for (int i = 0; i < 10; i++)
            {
                cmd.Parameters[0].Value = "test col-" + i;
                cmd.Parameters[1].Value = "test col " + (i * 2 + 1);
                cmd.AddBatch();
            }

            log.Info("Execute batch");
            cmd.ExecuteNonQuery();

            //Check all inserted data
            log.Info("Check all inserted data");
            cmd.Parameters.Clear();
            cmd.CommandText = "select * from t0";
            EsgynDBDataReader dr = cmd.ExecuteReader();
            while (dr.Read())
            {
                for (int i = 0; i < dr.FieldCount; i++)
                {
                    log.Info(dr.GetValue(i) + " " + dr.GetDataTypeName(i));
                }

            }
        }
コード例 #8
0
        public void TestBatch()
        {
            try
            {
                using (EsgynDBConnection conn = new EsgynDBConnection())
                {
                    conn.ConnectionString = ConnectionString;
                    conn.Open();

                    using (EsgynDBCommand cmd = conn.CreateCommand())
                    {
                        try
                        {
                            cmd.CommandText = "drop table t0";
                            cmd.ExecuteNonQuery();
                        }
                        catch (Exception e)
                        {
                            log.Warn(e.Message);
                        }

                        cmd.CommandText = "create table t0 (c1 varchar(20), c2 nchar(20)) no partition";
                        cmd.ExecuteNonQuery();

                        cmd.CommandText = "insert into t0 values(?,?)";
                        cmd.Parameters.Add(new EsgynDBParameter("c0", EsgynDBType.Varchar));
                        cmd.Parameters.Add(new EsgynDBParameter("c1", EsgynDBType.Varchar));

                        cmd.Prepare();

                        for (int i = 0; i < 10; i++)
                        {
                            if (i == 2)
                                cmd.Parameters[0].Value = "test col1";
                            else
                                cmd.Parameters[0].Value = "test col1rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr";
                            cmd.Parameters[1].Value = "test col2";
                            cmd.AddBatch();
                            log.Info(cmd.Parameters[0].Value);
                        }

                        //cmd.ExecuteNonQuery();
                        //Console.Read();

                        cmd.ExecuteNonQuery();

                        log.Info("start to select ....");
                        cmd.Parameters.Clear();
                        cmd.CommandText = "select * from t0";
                        using (EsgynDBDataReader dr = cmd.ExecuteReader())
                        {
                            while (dr.Read())
                            {
                                for (int i = 0; i < dr.FieldCount; i++)
                                {
                                    log.Info(dr.GetValue(i) + " " + dr.GetDataTypeName(i));
                                }

                            }

                        }
                    }
                }
            }
            catch (EsgynDBException e)
            {
                log.Info(e.ToString());
                for (int i = 0; i < e.Errors.Count; i++)
                {
                    log.Info(e.Errors[i]);
                }

            }
        }