At app runtime, PowerServer uses the database native .NET Core driver to connect with the database. These database drivers will be automatically downloaded from Nuget (www.nuget.org) to PowerServer C# solution when the solution is loaded in SnapDevelop. All you need to do is to select the database driver and agree to the driver license terms in the PowerBuilder IDE and then re-generate the PowerServer C# solution.
To select and agree to download the driver to the PowerServer solution:
-
Open the Database Configuration window from the PowerBuilder IDE.
-
Click DB Drivers in the Database Configuration window.
-
In the Required Database Drivers window, select the driver that will be used by PowerServer and the option "I have read and agree to the license ..."; and then click OK.
If the database cache has already been created, then the database driver is automatically selected.
-
Click the Build & Deploy PowerServer Project button in the toolbar to generate the PowerServer C# solution.
The selected driver will be automatically downloaded from the NuGet site to the PowerServer C# solution when the solution is loaded in SnapDevelop later.
At app runtime, PowerServer determines which database connection cache to use according to the transaction object in use (the connection string in the PowerScript will be ignored). Therefore, you are required to map the transaction object with the database connection cache.
After the database connection cache is created in the Database Configuration dialog (see Part 1: Configuring database connection for project compilation), for each transaction object that exists in the application, you can map it with the cache and then deploy these settings to the PowerServer C# solution. PowerServer will use these settings to set up static database connection for the app runtime.
This section will only focus on how to create the static mapping between transaction object and database cache. For how to dynamically create the database connection, refer to Setting up dynamic database connection for the app runtime.
To configure the static mapping of the transaction object with the cache:
-
Open the Database Configuration window from the PowerBuilder IDE.
-
In the Transaction-to-cache mappings section, input the transaction object name (for example "sqlca") and then select one of the configured caches to map with.
You only need to map the transaction objects that are used by the current application.
-
Click the Build & Deploy PowerServer Project button in the toolbar.
The transaction-to-cache mapping (as well as the cache settings) will be deployed to the PowerServer C# solution. PowerServer will directly use them for database connections at runtime.