Official Content

The following is an explanation of how to configure a local SQL Server or PostgreSQL database for prototyping and connect it to GeneXus Next running in a container.

SQL Server

Enable TCP/IP 

  • Open SQL Server Configuration Manager.
  • Navigate to SQL Server Network Configuration and click on the arrow > located to the left of its name to expand the section. This will display the available protocols for your SQL Server instance, such as Protocols for MSSQLSERVER.
  • In the list of protocols in the right pane, make sure that TCP/IP has the status Enabled. If it is not enabled, right-click on TCP/IP and select Enable.
  • Right-click on TCP/IP and select Properties. Next, navigate to the IP Addresses tab. In the IPAll section, configure the following:
    • TCP Dynamic Ports: Leave this field empty if you want to specify a fixed port.
    • TCP Port: Enter the desired port number, such as 1444.
  • Once you've made the changes, click on Apply to save them.
    SQL_2024112819833_1_png
  • Open the Services application on your computer. Locate your SQL Server instance in the list of services. For example, in the image, it is labeled as SQL Server (MSSQLSERVER). Right-click on the SQL Server instance name, and from the context menu, select Restart. 
    SQL2_png

Create a new database use

  • Open Microsoft SQL Server Management Studio (SSMS) and connect to your SQL Server instance.
  • In the Object Explorer, right-click on the root node (your server instance name) and select Properties. Navigate to the Security page in the left-hand menu. Under Server Authentication, select SQL Server and Windows Authentication mode. Click on OK to save the changes.
    SQL3_png
  • Open the Services application on your computer. Locate your SQL Server instance (For example, SQL Server (MSSQLSERVER) or SQL Server (SQLEXPRESS2022)). Right-click on the service and select Restart
  • Return to SSMS after restarting the SQL Server service. In the Object Explorer, expand the Security folder and right-click on Logins
  • Select New Login to open the Login – New dialog, and configure the following settings in the General section:
    SQL4_png
    • Login name: Enter the desired username (e.g., GXlogin).
    • Select SQL Server authentication.
    • Password: Set a secure password and confirm it by re-entering the password.
  • After creating the login, navigate to the Server Roles section in the Login – New dialog. Assign the required server-wide roles by selecting the corresponding boxes. In this case, select the roles dbcreator, public, and serveradmin.
    SQL5_png
  • After creating the login, navigate to the User Mapping section in the Login – New dialog. Select the boxes next to the databases where the user should have access. For this setup, select master and model
  • Assign the following database roles for master:
    • db_datareader
    • db_datawriter
    • db_ddladmin
    • public (default role, always selected)

    Click on OK to save the configuration.
    SL6Q_png

Configure GeneXus Next

In GeneXus Next, go to the PREFERENCES window, and select the Default Data Store. Next, set the following properties:

SQL7_png

  • Database Name: (Your Database Name)
  • Server Name: host.docker.internal
  • Server TCP/IP port: 1444
  • Used trusted connection: No
  • User ID: (Your New User)
  • Password: (Your New User's Password)

Notes:

  • 'host.docker.internal' always refers to the Docker host machine (localhost)
  • Port 1444 is used to avoid conflicts with the default SQL Server port (1433) used by the sql-1 container

PostgreSQL

Install and Run PostgreSQL using Docker

  • Ensure Docker Desktop is running in Linux mode on Windows.
  • Open a Command Prompt and run the following commands:
    docker pull pgvector/pgvector:pg16
    docker run --env=POSTGRES_PASSWORD=admin -p 5432:5432 -d pgvector/pgvector:pg16

Configure GeneXus Next Datastore Properties

In GeneXus Next, go to the PREFERENCES window, and select the Default Data Store. Next, set the following properties:

SQL8_png

  • Database:  (Your Database Name)
  • Server Name: host.docker.internal
  • Server TCP/IP port: 5432
  • User ID:  postgres
  • User Password: admin

Notes:

  • The 'host.docker.internal' address allows the GeneXus container to communicate with the PostgreSQL container on the host machine.
  • Port 5432 is the default PostgreSQL port.
  • Ensure your firewall allows connections on this port.
  • If you plan to use the Embedding data type in your GeneXus Next applications, you need to set up a PostgreSQL database.

Troubleshooting:

  • If the connection fails, check if the PostgreSQL container is running using docker ps.
  • Verify that the port mapping is correct in the Docker run command.
  • Ensure no other services are using port 5432 on your machine.

See Also

Getting Started with GeneXus Next - Generating and running the application

 

Last update: November 2024 | © GeneXus. All rights reserved. GeneXus Powered by Globant