Enabling long connections

As described in long-running connections vs. short-lived connections, if your application uses features that require the same database connection in a native C/S app, these features may fail to work well in installable cloud apps, in which different database connections will be selected from the pool for the features.

For example, if a temp table is used in the application:

  • In the traditional client/server application, the temp table will not be destroyed until the DISCONNECT statement is executed, so after this temporary table is created, you can perform operations with this temp table at any area you like.

  • In the installable cloud apps, if the temp table is created in connection A, and operations in connection B try to access this temp table, then errors such as "table not found" will occur. Or the temp table created in connection A is destroyed when connection A is returned to the pool, then operations with this temp table will fail even though connection A is selected again from the pool.

You cannot get the expected result in the installable cloud app, because the temp table is only valid in the current database connection (which is a short-lived connection).

Workaround

To eliminate this difference, you can use the LongConnection database parameter to enable the installable cloud app to persistently use the same database connection for a particular client. For example,

DBParm = Database='nvo2csharp', Provider='SQLNCLI11', LongConnection=1

LongConnection=1 enables the installable cloud app to have the same long-running connection as the PowerBuilder native C/S app. Take the local temp table as an example, LongConnection=1 makes the same database connection to be used during the whole user session, therefore, the local temp table will stay active all the time and the same temp table will be used during the whole user session.

Besides that, it is highly recommended to increase the transaction timeout value (120 seconds by default) to have the same interval as the session timeout value (3600 seconds by default). This is to prevent transaction timeout during the session. Because if the transaction times out, then a new database connection will be created, which means the temp table is not the same one. For how to set transaction timeout values, refer to Configure the timeout settings.