Connect to the database when moving from direct connection to HTTP

Understand the changes in database connection behavior and what to review when transitioning to HTTP-based deployment using Genero Application Server (GAS).

What has changed

When moving from Direct Connection to HTTP-based deployment with GAS, the application no longer runs under the identity of the physical end user. Instead, it runs under the operating system user associated with the web server (for example, apache).

This change affects:

  • Process owner: The application is now executed by the GAS runtime user, not the logged-in end user.

  • Environment variables: Variables such as $HOME and others derived from the OS user context may no longer reflect the end user's environment.

  • SQL USER value: The value returned by the USER keyword in SQL statements may reflect the GAS user unless explicitly set during the database connection.

What to review in your application

To ensure correct behavior after introducing GAS, review the following areas in your application source and configuration:

  • Database connection logic: Any use of DATABASE or CONNECT TO statements should be reviewed to ensure the correct database user is used.

  • SQL statements using USER: If your application relies on the USER keyword to identify the end user, consider how this value is affected by the GAS runtime context.

  • Environment-dependent logic: Any logic that depends on $HOME or other user-specific environment variables may need to be refactored.

Connecting to the database

After the application is started by GAS, it must connect to the database using valid credentials. The most common method is:


MAIN
DEFINE uname, upswd VARCHAR(50)
...
CONNECT TO "dbsource" USER uname USING upswd
...
END MAIN
Other things to consider:

In web applications with dynamic user populations, it is recommended to use predefined database users mapped to application roles. This approach simplifies user management and enhances security. For details, refer to the Database users and security topic in the Genero Business Development Language User Guide.

Depending on your architecture, application-level authentication may still be required. This can be implemented locally against a database or delegated to an identity provider using Single Sign-On (SSO):
  1. For database-based authentication, refer to Database user authentication in the Genero Business Development Language User Guide.
  2. For SSO-based authentication, refer to Connect to the application database with SSO in the Single Sign-On User Guide.