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:
- In G2, open your G2 application.
- Merge the ODBC KB into your G2 application.
- Choose Main Menu > Merge KB.
- In your File Explorer, navigate to <G2 Installation folder>/odbc/kbs and locate the g2-database.kb file.
- Enter the path to the file in the Text Editor for File Command window.
- Choose the merge in this KB and automatically resolve all conflicts options and press Enter.
- Click on OK.
Note: The G2 Database Bridge requires sys-mod.kb and uilroot.kb.
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.
- Create one or more G2-Database interface objects.
- Start the G2 application.
- Select Main Menu > Get Workspace > g2-database
- Click on the IO button. The g2-database connection configuration workspace will open.
- Click on the example-interface and choose clone. A cloned instance of the interface object appears attached to your mouse.
- 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.
- Set the attributes of the G2-Database interface objects.
- Right click the g2-database-interface object that you created in the previous step and click on table.
- 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.
- 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.
- 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.