Ejemplo n.º 1
0
        internal DbConnection OpenConnection()
        {
            DbConnection connection = DbDriver.CreateConnection();
            int          times      = 2;

            while (times > 0)
            {
                times--;
                try
                {
                    if (connection.State != ConnectionState.Open)
                    {
                        connection.Open();
                        if (ConnectionState.Open == connection.State)
                        {
                            times = -1;
                        }
                    }
                    else
                    {
                        times = -1;
                    }
                }
                catch (Exception ex)
                {
                    if (times == 0)
                    {
                        throw new DataException("Connection Failed." + connectionName, ex);
                    }
                    Thread.Sleep(0x3e8);
                }
            }
            return(connection);
        }
Ejemplo n.º 2
0
        public static bool TestConnection(DbDriver driver, string connString, out string message)
        {
            message = null;
            var conn = driver.CreateConnection(connString);

            try {
                conn.Open();
                conn.Close();
                return(true);
            } catch (Exception ex) {
                message = " Connection test failed: " + ex.Message;
                return(false);
            }
        }//method
Ejemplo n.º 3
0
        private static void CheckConnectivity(DbDriver driver, string connectionString)
        {
            IDbConnection conn = null;

            try {
                conn = driver.CreateConnection(connectionString);
                conn.Open();
            } finally {
                if (conn != null)
                {
                    conn.Close();
                }
            }
        }
Ejemplo n.º 4
0
 public MySQL5xOperator(string connectionString, DbDriver driver) : base(connectionString, driver)
 {
     _connection = DbDriver.CreateConnection(ConnectionString);
 }