コード例 #1
0
        public static SqlConnectionPool Instance(SqlDBCredentials credentials)
        {
            SqlConnectionPool retVal = s_PoolList.Find(credentials);

            if (retVal == null)
            {
                retVal = new SqlConnectionPool(credentials);
                s_PoolList.Add(retVal);
            }
            return(retVal);
        }
コード例 #2
0
        protected DataSourceBase(SqlDBCredentials sqlCredentials)
        {
            _internalDatabaseType = InternalDatabaseType.Unknown;
            Credentials           = sqlCredentials;
            m_DB = SqlConnectionPool.Instance(sqlCredentials).GetDataSource();

            if (m_DB == null)
            {
                throw new DataSourceException("Could not instantiate {0} with the following credentials: {1}", GetType(), sqlCredentials);
            }

            if (CheckDeclarations)
            {
                ValidateMethods(GetType());
            }

            LoadCachedTypeInformation();
        }
コード例 #3
0
        public static DBResult GetDatabaseVersion(SqlDBCredentials credentials, out SoftwareVersion version, out InternalDatabaseType databaseType)
        {
            DBResult retVal = new DBResult(DBResult.Result.Success);

            try
            {
                _databaseVersionLock.Lock();
                version      = null;
                databaseType = InternalDatabaseType.Unknown;
                String indexKey = credentials.ToParsableString();
                if (!_databaseVersionLookup.TryGetValue(indexKey, out version))
                {
                    ISqlDataSource     ds = SqlConnectionPool.Instance(credentials).GetDataSource();
                    DatabaseDataReader reader;

                    QueryString sql = ds.FormatTrusted("SELECT * FROM I.seq where name in ('{0}', '{1}')", KEY_DB_TYPE, KEY_SCHEMA_VER);
                    retVal = ds.Query(sql, out reader);
                    if (retVal.ResultCode == DBResult.Result.Success && reader.HasRows)
                    {
                        while (reader.Read())
                        {
                            String key = DBUtil.GetString(reader[COL_KEY]);
                            if (key == KEY_SCHEMA_VER)
                            {
                                version = DBUtil.GetSoftwareVersion(reader[COL_VALUE]);
                            }
                            else if (key == KEY_DB_TYPE)
                            {
                                databaseType = (InternalDatabaseType)DBUtil.GetInt32(reader[COL_VALUE]);
                            }
                        }
                        _databaseVersionLookup.Add(indexKey, version);
                    }
                }
            }
            finally
            {
                _databaseVersionLock.Unlock();
            }
            return(retVal);
        }
コード例 #4
0
ファイル: DBUtil.cs プロジェクト: StevePunak/KanoopCommon
 public void Init(SqlDBCredentials creds)
 {
     m_Credentials   = creds;
     m_sqlDataSource = SqlConnectionPool.Instance(m_Credentials).GetDataSource();
 }