A developer has several options for establishing database connections for installable cloud apps.
Option | Connection required for project compilation | Connection required for the app runtime |
---|---|---|
#1 | Create the caches in the project settings > Database Configuration window. For more information, refer to Configuring database caches. | Dynamic database connection --- Specify which cache will be used by the transaction object in PowerScript. For more information, refer to Dynamically mapping transaction object with cache. |
#2 | Create the caches in the project settings > Database Configuration window. For more information, refer to Configuring database caches. | Static database connection --- Map the transaction object with the cache in the project settings > Database Configuration window. For more information, refer to Setting up static database connection for the app runtime. |
#3 | Create the caches in the project settings > Database Configuration window. For more information, refer to Configuring database caches. | Static database connection --- Directly specify the database connection information in PowerScript. For more information, refer to Making dynamic database connections from the app client. |
With either of the options, you need to create the cache in the Database Configuration window, because it is required for project compilation: the cache information is necessary for converting the DataWindows to C# models.
If you have configured more than one options, the priority order to take the options is: #1 -> #2 -> #3. Option #3 is not recommended for the production environment because of security concerns. Different from the other two options (which stores the database connection information in PowerServer), #3 stores the database connection information at the app client and has higher risk of exposing the sensitive connection information.
As you can tell from the above table, during the app runtime, there are two ways to connect with the database: static database connection, or dynamic database connection.
-
"Static database connection" (option #2) means the connection configuration (including connection cache settings, and transaction-to-cache mappings) is created before the app is run. The connection configuration is initially created in the Database Configuration window and gets deployed to the PowerServer C# solution. Although you may further update the connection configuration in the solution, the configuration from the solution will be used during the app runtime.
-
"Dynamic database connection" means the mapping is created when the app is run. A dynamic mapping can be created in the application scripts using the DBParm CacheName property (option #1) or using the transaction connections (option #3).