The following error may occur when trying to make a new database connection to DB2 after calling xa_close():
SQL1248N Database "<database-alias>" not defined with the transaction
- xa_close() resets the XA environment only when "Thread of Control" is set to PROCESS.
- The connection type should be set back to 1 again before making a new connection
Resolving the problem
To resolve this problem, do the following:
1. In order to ensure the XA environment is reset after calling xa_close(), "Thread of Control" needs to be set to "PROCESS" by adding "TOC=P" to the XA open string.
2. After calling xa_close(), the connection type should be set to 1 by using the sqlesetc API. This should be done before attempting a new connection.
int rc = 0;
struct sqlca ljsqlca;
struct sqle_conn_setting csetting;
csetting.type = SQL_CONNECT_TYPE;
csetting.value = SQL_CONNECT_1;
rc = sqlesetc( &csetting, 1, &ljsqlca);