I need to open connection to system DB and then internally open connection for tenant DB. Currently i have implemented having different environment handle for each connection.
Connecting to system DB,
retCode = SQLAllocConnect(sqlEnvHandle , &sqlConnectionHandle);
retCode=SQLDriverConnect (sqlConnectionHandle,
NULL,
(SQLCHAR*)ConnString,
SQL_NTS,
retConnString,
BUFFER_SIZE,
NULL,
SQL_DRIVER_NOPROMPT);
Connecting to tenant DB where 'i' iterated to number of tenant DB and opens connection for each tenant DB,
retCode = SQLAllocConnect(TenantDBConnectionObj[i].sqlTenantEnvHandle, &TenantDBConnectionObj[i].sqlTenantConnectionHandle);
retCode=SQLDriverConnect(TenantDBConnectionObj[i].sqlTenantConnectionHandle,
NULL,
ConnString,
SQL_NTS,
retConnString,
BUFFER_SIZE,
NULL,
SQL_DRIVER_NOPROMPT);
Is it effective programming to open all these connection with just one environment handle sqlEnvHandle
?
What about connection pooling ? Can we implement in such scenario?