public RunlogDatabaseHandler(RunLogDatabaseSettings databaseSettings)
        {
            if (conn != null)
            {
                throw new RunLogDatabaseException("Attempted to re-open a database connection without first closing the same handle.");
            }

            string connStr = databaseSettings.getConnectionString();
            this.conn = new MySqlConnection(connStr);
            try
            {
                conn.Open();
            }
            catch (Exception ex)
            {
                try { conn.Close(); } catch(Exception) {};

                conn = null;
                RunLogDatabaseException newex = new RunLogDatabaseException("Unable to open database due to exception: " + ex.Message, ex);
                throw newex;
            }
        }
Example #2
0
        public RunlogDatabaseHandler(RunLogDatabaseSettings databaseSettings)
        {
            if (conn != null)
            {
                throw new RunLogDatabaseException("Attempted to re-open a database connection without first closing the same handle.");
            }

            string connStr = databaseSettings.getConnectionString();

            this.conn = new MySqlConnection(connStr);
            try
            {
                conn.Open();
            }
            catch (Exception ex)
            {
                try { conn.Close(); } catch (Exception) {};

                conn = null;
                RunLogDatabaseException newex = new RunLogDatabaseException("Unable to open database due to exception: " + ex.Message, ex);
                throw newex;
            }
        }