예제 #1
0
        /// <summary>
        /// Configures a new Database-connection that can be accessed from everywhere.
        /// </summary>
        /// <param name="connectionParameter">An Object that stores the connection-details.</param>
        /// <returns>True if the connection configuration was successful.</returns>
        /// <author>Jannik Arndt, Bernd Nottbeck</author>
        public static bool ConfigureDBConnection(ConnectionParameters connectionParameter)
        {
            if (String.IsNullOrEmpty(connectionParameter.Type))
            {
                throw new ConnectionTypeNotGivenException();
            }

            if (connectionParameter.Type.Equals("SQLite") || connectionParameter.Type.Equals("SQLite In-Memory"))
            {
                if (String.IsNullOrEmpty(connectionParameter.Database))
                {
                    throw new NoParamsGivenException();
                }
            }
            else
            {
                if (String.IsNullOrEmpty(connectionParameter.Database) || String.IsNullOrEmpty(connectionParameter.Host) ||
                    String.IsNullOrEmpty(connectionParameter.Name) || String.IsNullOrEmpty(connectionParameter.Port))
                {
                    throw new NoParamsGivenException();
                }
            }

            DbConnectionParameter = connectionParameter;

            switch (connectionParameter.Type)
            {
            case "MySQL":
                DatabaseConnection = new MPMMySQLConnection(connectionParameter);
                return(true);

            case "Oracle":
                DatabaseConnection = new MPMOracleSQLConnection(connectionParameter);
                return(true);

            case "PostgreSQL":
                DatabaseConnection = new MPMPostgreSQLConnection(connectionParameter);
                return(true);

            case "MS-SQL":
                DatabaseConnection = new MPMMicrosoftSQL(connectionParameter);
                return(true);

            case "MS-SQL Windows Auth":
                DatabaseConnection = new MPMMicrosoftSQL(connectionParameter, false);
                return(true);

            case "SQLite":
                DatabaseConnection = new MPMSQLiteConnection(connectionParameter);
                return(true);

            case "SQLite In-Memory":
                DatabaseConnection = new MPMSQLiteConnection(connectionParameter, true);
                return(true);

            default:
                throw new DatabaseDoesNotExist();
            }
        }
예제 #2
0
        /// <summary>
        /// Configures a new Database-connection that can be accessed from everywhere.
        /// </summary>
        /// <param name="connectionParameter">An Object that stores the connection-details.</param>
        /// <returns>True if the connection configuration was successful.</returns>
        /// <author>Jannik Arndt, Bernd Nottbeck</author>
        public static bool ConfigureDBConnection(ConnectionParameters connectionParameter)
        {
            if (String.IsNullOrEmpty(connectionParameter.Type))
                throw new ConnectionTypeNotGivenException();

            if (connectionParameter.Type.Equals("SQLite") || connectionParameter.Type.Equals("SQLite In-Memory"))
            {
                if (String.IsNullOrEmpty(connectionParameter.Database))
                    throw new NoParamsGivenException();
            }
            else
            {
                if (String.IsNullOrEmpty(connectionParameter.Database) || String.IsNullOrEmpty(connectionParameter.Host) ||
                String.IsNullOrEmpty(connectionParameter.Name) || String.IsNullOrEmpty(connectionParameter.Port))
                    throw new NoParamsGivenException();
            }

            DbConnectionParameter = connectionParameter;

            switch (connectionParameter.Type)
            {
                case "MySQL":
                    DatabaseConnection = new MPMMySQLConnection(connectionParameter);
                    return true;
                case "Oracle":
                    DatabaseConnection = new MPMOracleSQLConnection(connectionParameter);
                    return true;
                case "PostgreSQL":
                    DatabaseConnection = new MPMPostgreSQLConnection(connectionParameter);
                    return true;
                case "MS-SQL":
                    DatabaseConnection = new MPMMicrosoftSQL(connectionParameter);
                    return true;
                case "MS-SQL Windows Auth":
                    DatabaseConnection = new MPMMicrosoftSQL(connectionParameter, false);
                    return true;
                case "SQLite":
                    DatabaseConnection = new MPMSQLiteConnection(connectionParameter);
                    return true;
                case "SQLite In-Memory":
                    DatabaseConnection = new MPMSQLiteConnection(connectionParameter, true);
                    return true;
                default:
                    throw new DatabaseDoesNotExist();
            }
        }
예제 #3
0
 /// <summary>
 /// Resets the internal DatabaseConnection-connection and the connection parameters.
 /// </summary>
 public static void Reset()
 {
     DatabaseConnection    = null;
     DbConnectionParameter = null;
 }
예제 #4
0
 /// <summary>
 /// Resets the internal DatabaseConnection-connection and the connection parameters.
 /// </summary>
 public static void Reset()
 {
     DatabaseConnection = null;
     DbConnectionParameter = null;
 }