This sample shows how to use the solidDB Grid functionality with an ODBC application.
The files for the sample are located in the soliddb-installdir\samples\grid_odbc directory. For general information about running the samples, see Samples.
The sample application (gridsample.c) completes the following actions:
1 List the current grid configuration.
2 Use different connect strings to connect to the grid by using the grid-aware driver, and to individual nodes by using standard ODBC connections.
3 Create a non-partitioned (shared) table and demonstrate that, if you are using a standard ODBC connection, you must explicitly connect to the grid leader in order to insert records into the table. However, if you use the grid-aware driver to connect to the grid, you are automatically directed to the grid leader to insert records.
4 Create a partitioned table and demonstrate that, if you are using a standard ODBC connection, attempts to insert records only succeed if you connected to the node that hosts the primary replication unit (primary partition) for the row. However, if you use the grid-aware driver to connect to the grid, you are automatically directed to the node that hosts the primary partition to insert each record.
5 Attempt a set of inserts as a single transaction, meaning that the node that hosts the primary partition is identified for first row and same node is used for subsequent inserts until the insert fails. At which point, rows that were inserted successfully are committed and the transaction starts again with the row that failed. This strategy is more efficient if you are able to identify rows that belong to the same partition and insert them at the same time.
6 List the contents of the partitioned table to show that all records have been inserted successfully.
7 Demonstrate how to continue working if a node becomes unavailable.
Running the sample
Run the runme script (runme.bat on Windows) to compile the application, start four servers, create a grid from the servers, run the application, and shut down the servers.