internal MySQLConnection(string databaseDSNFile, DbConnection connection)
            : base(databaseDSNFile)
        {
            if (connection == null)
            {
                throw new Exception("Connection definition cannot be null!");
            }

            this.ServerAddress = connection.Server;
            this.Database = connection.Database;
            this.Username = connection.Username;
            this.Password = connection.Password;

            if (!File.Exists(this.DSNFile))
            {
                this.CreateDSNFile();
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Creates LISpMiner with given database. Only supported metabase is Access DB.
        /// </summary>
        /// <param name="environment">Environment settings.</param>
        /// <param name="id">Desired ID.</param>
        /// <param name="connection">Connection to original database.</param>
        /// <param name="metabaseConnection">Name of metabase file to use. Must exist in data folder.</param>
        public LISpMiner(Environment environment, string id, DbConnection connection, DbConnection metabaseConnection, bool sharedPool)
            : this(environment, id, sharedPool)
        {
            string databaseFile;
            string databaseDSNFile;

            string databasePrototypeFile = this.GetDatabaseNames(connection.Database, out databaseFile, out databaseDSNFile);

            if (connection.Type == OdbcDrivers.MySqlConnection)
            {
                this.Database = new MySQLConnection(databaseDSNFile, connection);
            }
            else
            {
                this.Database = new AccessConnection(databaseDSNFile, databaseFile, databasePrototypeFile);
            }

            if (this.Database == null)
            {
                throw new NullReferenceException("Database can't be null.");
            }

            this.CreateMetabase(metabaseConnection);
        }
Esempio n. 3
0
        protected void CreateMetabase(DbConnection metabaseConnection)
        {
            string metabaseFile;
            string dsnFile;
            string metabasePrototypeFile = metabaseConnection != null ? metabaseConnection.Filename : string.Empty;

            this.GetMetabaseNames(out metabaseFile, ref metabasePrototypeFile, out dsnFile);

            this.Metabase = new AccessConnection(dsnFile, metabaseFile, metabasePrototypeFile);

            this.Metabase.SetDatabaseDsnToMetabase(this.Database);
        }