Creating an ODBC Connection using the G2-ODBC Bridge


You want to know how an ODBC connection can be created from scratch in G2 using the G2 ODBC Bridge. This article provides the steps to include the bridge in your G2 application and establish a connection with your database, so data can be acquired from it.


  • A license for the ODBC bridge has been provided and installed.
  • G2 has been installed.


The G2-ODBC Bridge, which is included in the G2 bundle installation and can be found in <G2 Installation folder>/odbc,  provides connectivity between G2 and any relational database by using Microsoft's ODBC interface. It is designed to communicate with any database and on any platform that provides an ODBC driver. To enable data service between G2 and your database using the ODBC bridge:

  1. In G2, open your G2 application.
  2. Merge the ODBC KB into your G2 application.
    1. Choose Main Menu > Merge KB.
    2. In your File Explorer, navigate to <G2 Installation folder>/odbc/kbs and locate the g2-database.kb file.
    3. Enter the path to the file in the Text Editor for File Command window.
    4. Choose the merge in this KB and automatically resolve all conflicts options and press Enter.
    5. Click on OK.

      Note: The G2 Database Bridge requires sys-mod.kb and uilroot.kb.

    6. Choose Save KB to save the resulting knowledge base.

      Note: It is recommended practice to modularize any G2 application that uses a G2-Database bridge or bridge knowledge base. Refer to the G2-Database Bridge User’s Guide available in <G2 Installation folder>/doc/bridges/db for more information. 

  3. Create one or more G2-Database interface objects.
    1. Start the G2 application. 
    2. Select Main Menu > Get Workspace > g2-database
    3. Click on the IO button. The g2-database connection configuration workspace will open.
    4. Click on the example-interface and choose clone. A cloned instance of the interface object appears attached to your mouse.
    5. Transfer the cloned interface object to a workspace in your application, other than a G2-Database KB workspace, clicking the mouse to release the object.

      Note: When you close the example-interface, the cloned interface object is disabled by default. You must enable the cloned G2-Database interface object later by selecting enable from its property table.

  4. Set the attributes of the G2-Database interface objects.
    1. Right click the g2-database-interface object that you created in the previous step and click on table.
    2. Specify all the required attributes to configure a connection between G2 and the bridge and to enable the bridge to establish a connection to a database.
      • gsi-connection-configuration: Specifies the network protocol that G2 uses to communicate with the bridge. Should be specified as tcp-ip host "hostname" port-number tcp-ip-port number.
      • database-user: Specifies the database user name, which the bridge uses when it establishes a connection to the database.
      • database-password: Specifies the database user password, which the bridge uses when it establishes a connection to the database.
      • database-connect-string: Specifies the database connection information that the bridge uses to build the complete database connection string to establish a connection to the database.

      Note: Refer to the G2-Database Bridge User’s Guide available in <G2 Installation folder>/doc/bridges/db for more information about these and other attributes in the table.

  5. Start the bridge by executing the run-g2-odbc.bat file found in <G2 installation folder>\odbc\bin via Command Prompt or Terminal, depending on your operating system.
  6. After the bridge process has been started, enable the g2-database-interface object that was configured in step 4. This is done by right-clicking on the object and selecting enable.


Once you have a connection established, you can run queries for data. Several procedures are provided for this purpose. Refer to the G2-Database Bridge and G2 ODBC Bridge documentation for further detail.




Please sign in to leave a comment.