sqldata/sqldb.cpp
// Create database API object for source database
Create database API object for source database
Create database API object for source database
SqlApiBase* SqlDb::CreateDatabaseApi(const char *conn, short *type)
{
	if(conn == NULL)
		return NULL;
	SqlApiBase *db_api = NULL;
	const char *cur = Str::SkipSpaces(conn);
	if(_strnicmp(cur, "oracle", 6) == 0)
	{
		db_api = new SqlOciApi();
		cur += 6;
		if(type != NULL)
			*type = SQLDATA_ORACLE;
	}
	else
	if(_strnicmp(cur, "sql", 3) == 0)
	{
		db_api = new SqlSncApi();
		cur += 3;
		if(type != NULL)
			*type = SQLDATA_SQL_SERVER;
	}
	else
	if(_strnicmp(cur, "mysql", 5) == 0)
	{
		db_api = new SqlMysqlApi();
		cur += 5;
		if(type != NULL)
			*type = SQLDATA_MYSQL;
	}
    else
	if(_strnicmp(cur, "mariadb", 7) == 0)
	{
		db_api = new SqlMysqlApi();
		db_api->SetSubType(SQLDATA_SUBTYPE_MARIADB);
		cur += 7;
		if(type != NULL)
			*type = SQLDATA_MYSQL;
	}
	else
	if(_strnicmp(cur, "pg", 2) == 0)
	{
		db_api = new SqlPgApi();
		cur += 2;
		if(type != NULL)
			*type = SQLDATA_POSTGRESQL;
	}
	else
	if(_strnicmp(cur, "sybase", 6) == 0)
	{
		db_api = new SqlCtApi();
		cur += 6;
		if(type != NULL)
			*type = SQLDATA_SYBASE;
	}
#if defined(WIN32) || defined(_WIN64)
	else
	if(_strnicmp(cur, "asa", 3) == 0)
	{
		db_api = new SqlAsaApi();
		cur += 3;
		if(type != NULL)
			*type = SQLDATA_ASA;
	}
#endif
	else
	if(_strnicmp(cur, "informix", 8) == 0)
	{
		db_api = new SqlIfmxApi();
		cur += 8;
		if(type != NULL)
			*type = SQLDATA_INFORMIX;
	}
	else
	if(_strnicmp(cur, "db2", 3) == 0)
	{
		db_api = new SqlDb2Api();
		cur += 3;
		if(type != NULL)
			*type = SQLDATA_DB2;
	}
#if defined(WIN32) || defined(_WIN64)
	else
	if(_strnicmp(cur, "odbc", 4) == 0)
	{
		db_api = new SqlOdbcApi();
		cur += 4;
		if(type != NULL)
			*type = SQLDATA_ODBC;
	}
#endif
	else
	if(_strnicmp(cur, "stdout", 6) == 0)
	{
		db_api = new SqlStdApi();
		cur += 6;
		if(type != NULL)
			*type = SQLDATA_STDOUT;
	}
	cur = Str::SkipSpaces(cur);
	if(*cur == ':')
	{
		cur++;
		db_api->SetDriverType(cur);
		cur = Str::SkipUntil(cur, ',');
	}
	cur = Str::SkipSpaces(cur);
	if(*cur == ',')
		cur++;
	cur = Str::SkipSpaces(cur);
	if(db_api != NULL)
	{
		db_api->SetConnectionString(cur);
		db_api->SetParameters(_parameters);
		db_api->SetAppLog(_log);
	}
	return db_api;
}
SqlApiBase * SqlDb :: CreateDatabaseApi ( const char * conn , short * type ) { if ( conn == NULL ) return NULL ; SqlApiBase * db_api = NULL ; const char * cur = Str :: SkipSpaces ( conn ) ; if ( _strnicmp ( cur , " " , 6 ) == 0 ) { db_api = new SqlOciApi ( ) ; cur += 6 ; if ( type != NULL ) * type = SQLDATA_ORACLE ; } else if ( _strnicmp ( cur , " " , 3 ) == 0 ) { db_api = new SqlSncApi ( ) ; cur += 3 ; if ( type != NULL ) * type = SQLDATA_SQL_SERVER ; } else if ( _strnicmp ( cur , " " , 5 ) == 0 ) { db_api = new SqlMysqlApi ( ) ; cur += 5 ; if ( type != NULL ) * type = SQLDATA_MYSQL ; } else if ( _strnicmp ( cur , " " , 7 ) == 0 ) { db_api = new SqlMysqlApi ( ) ; db_api -> SetSubType ( SQLDATA_SUBTYPE_MARIADB ) ; cur += 7 ; if ( type != NULL ) * type = SQLDATA_MYSQL ; } else if ( _strnicmp ( cur , " " , 2 ) == 0 ) { db_api = new SqlPgApi ( ) ; cur += 2 ; if ( type != NULL ) * type = SQLDATA_POSTGRESQL ; } else if ( _strnicmp ( cur , " " , 6 ) == 0 ) { db_api = new SqlCtApi ( ) ; cur += 6 ; if ( type != NULL ) * type = SQLDATA_SYBASE ; } #if defined ( WIN32 ) || defined ( _WIN64 ) else if ( _strnicmp ( cur , " " , 3 ) == 0 ) { db_api = new SqlAsaApi ( ) ; cur += 3 ; if ( type != NULL ) * type = SQLDATA_ASA ; } #endif else if ( _strnicmp ( cur , " " , 8 ) == 0 ) { db_api = new SqlIfmxApi ( ) ; cur += 8 ; if ( type != NULL ) * type = SQLDATA_INFORMIX ; } else if ( _strnicmp ( cur , " " , 3 ) == 0 ) { db_api = new SqlDb2Api ( ) ; cur += 3 ; if ( type != NULL ) * type = SQLDATA_DB2 ; } #if defined ( WIN32 ) || defined ( _WIN64 ) else if ( _strnicmp ( cur , " " , 4 ) == 0 ) { db_api = new SqlOdbcApi ( ) ; cur += 4 ; if ( type != NULL ) * type = SQLDATA_ODBC ; } #endif else if ( _strnicmp ( cur , " " , 6 ) == 0 ) { db_api = new SqlStdApi ( ) ; cur += 6 ; if ( type != NULL ) * type = SQLDATA_STDOUT ; } cur = Str :: SkipSpaces ( cur ) ; if ( * cur == ' ' ) { cur ++ ; db_api -> SetDriverType ( cur ) ; cur = Str :: SkipUntil ( cur , ' ' ) ; } cur = Str :: SkipSpaces ( cur ) ; if ( * cur == ' ' ) cur ++ ; cur = Str :: SkipSpaces ( cur ) ; if ( db_api != NULL ) { db_api -> SetConnectionString ( cur ) ; db_api -> SetParameters ( _parameters ) ; db_api -> SetAppLog ( _log ) ; } return db_api ; }
Create database API object for source database
Create database API object for source database
// Check for Oracle OCI // Check for SQL Server Native Client // Check for MySQL C API // Check for MariaDB C API // Check for PostgreSQL libpq C library // Check for Sybase Client library // Sybase SQL Anywhere ODBC driver // Check for Informix library // Check for DB2 library // Check for ODBC // Check for Standard Output // Check driver type information // Skip comma after database type // Set the connection string and parameters in the API object