It is important to understand the following connection differences between the PowerBuilder traditional C/S app and the PowerServer installable cloud app.
Long-running connection vs. short-lived connection
In the PowerBuilder traditional client/server application, a client connects with the database when CONNECT statement is executed, and the database connection is kept open and used by that client until the DISCONNECT statement is executed, which means, 1) the database connection can remain open through the entire lifespan of the application; 2) for a particular client, the database connection is always the same one. This database connection is called "long-running connection".
In the installable cloud application, the database connection is made from PowerServer (not from the client), and the database connection is ended and returned to the connection pool when the transaction is completed, which means, for a particular client, it may use more than one connections through the entire lifespan of the application. This database connection is called "short-lived connection". This connection mechanism can support high concurrency and minimize table deadlocks. Additionally, short-lived connections are more secure and less vulnerable to network condition compared to long-running connections.
Note
These connection differences will cause a few features (that work in the long-running connection) to fail to work in the short-lived connection. For example, a temporary table created in the long-running connection can be used and accessed until the application is closed, while a temporary table created in the short-lived connection becomes inaccessible when that connection ends and returns to the pool.
To resolve this issue, you can take advantage of a parameter called LongConnection to enable the installable cloud app to have the same long-running connection as the PowerBuilder traditional C/S app. For more information, refer to Long connection.
client-to-server connections vs. server-to-server connections
The PowerBuilder traditional client/server application directly connects with the database server from the client (client-to-server connections). The database driver must be installed on the client. The database connection information (including user ID, password, DB connection string, etc.) must be stored at the client and transferred between the client and the database when the database connection is created.
The installable cloud application provides a more secure way, in which the database connection is made from PowerServer to the database server (server-to-server connections), the database driver is installed in PowerServer, and the connection information is stored in a cache in PowerServer and transferred between the PowerServer and the database server. The PowerServer and the database can reside in the LAN behind the firewall.
Note
For the installable cloud app to work, you will need to create a cache and then map the transaction object to the cache.
Following outlines the key steps to implement a server-to-server connection in the installable cloud app (for detailed instructions, refer to this section):
-
A database connection cache must be created.
The cache stores the database connection information. Normally, the cache is created in the IDE and used by the IDE to connect with the database and convert the DataWindows to PowerServer C# models; after the cache is deployed from the IDE to PowerServer, it is used by PowerServer to connect with the database when the application is run.
Note
The .NET Core data provider enforces strict validation rules on the data type and length, therefore, the IDE reads information about tables, columns, constraints, and indexes from the actual database in order to generate the PowerServer C# models correctly. If the data source is a stored procedure, the stored procedure will be executed to get the schema information.
-
The transaction object(s) must be mapped with the cache.
For each transaction object used in the application, it must be mapped with a cache. The mapping will be used to set up database connection for the app runtime.
-
The .NET Core database provider must be downloaded to PowerServer.
Unlike the traditional client/server app which directly connects with the database through a local driver, the installable cloud app relies on the PowerServer Web APIs and the .NET Core database provider in PowerServer to connect with the database.
You must agree to the license terms of the driver so that the driver can be downloaded and used whenever necessary (for example, when generating the PowerServer C# models in the development PC, or compiling the Web APIs in the development PC or in the server). The download happens automatically in the development PC and the server after you have agreed to the license terms of the driver.