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); }
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
private static void CheckConnectivity(DbDriver driver, string connectionString) { IDbConnection conn = null; try { conn = driver.CreateConnection(connectionString); conn.Open(); } finally { if (conn != null) { conn.Close(); } } }
public MySQL5xOperator(string connectionString, DbDriver driver) : base(connectionString, driver) { _connection = DbDriver.CreateConnection(ConnectionString); }