company logo

DataSource :: DataSource - Create data source handle

The function creates a data source handle. When the data source is described completely in a option section in a configuration or ini-file, the data source can be created and opened in one step passing the configuration file (sIniFile) and the data source name (sDataSourceName).

Usually, the function refers to the main client handle, which will be created on demand when not being initialized by calling odaba::initializeApplication(). In order to connect via an application specific client, a client handle can be passed (rClient). When connecting a data source to a server, the function checks, whether the server fits to the client passed. When the client is already connected to a different server, the function automatically creates a new client handle. Client handle should be passed only, in order to optimize client connections.

Implementation overview

Implementation details

  1. Create data source with application client
    DataSource  :: DataSource ( odaba::Client &cClient, odaba::String &sIniFile, odaba::String &sDataSourceName )

    The function sets the client handle passed in rClient as client handle for the data source. The data source will be initialized from the option section with the name passed in sDataSourceName, which has to refer to an option section in the configuration file passed in sIniFile.

    When the data source could not be opened, the function throws an exception. The data source handle remains as initialized data source handle.

    // calling DataSource ds(rClient,"c:/temp/myAppl.ini","Test") is a short cut for:

      DataSourceHandle  dsh();

      setClient(rClient);

      dsh.initialize("c:/temp/myAppl.ini","Test");

      dsh.open();

    • cClient - Client handle

      The client handle refers to an (usually) opened ODABA client. Calling functions with invalid client handles may cause an exception. For checking the client handle, isValid() can be called.

    • sIniFile - Path to ini-file location

      The path may contain any type of folder separator ('/' or '\'). Folder separators will be converted according to the conventions of the target system.

      In order to pass no ini-file, an empty string ( String() ) has to be passed.

    • sDataSourceName - Data source name

      The name of the data source refers to a section in a configuration or ini-file or to a data source defined in the data catalog defined for the application. Other data source variables are set from the data source definition referred to by the data source name.

  2. to list
  3. Create data source handle copy
    DataSource  :: DataSource ( odaba::DataSource &cDataSource )

    The function copies the settings any handle opened in the passed data source. For opened access handles handle copies are created.

    • cDataSource - - internal feature (not documented)
  4. to list
  5. Create an empty data source
    DataSource  :: DataSource (  )

    The function creates an initialized data source. The constructor automatically creates a client handle for the main client, which is sufficient as long as the application need not to connect to more than one server.

    Before opening the data source, database paths, object and extent names have to be set. This can be done by explicitly setting the paths and names in the program or by means of a configuration or ini-file (initialize()) or by calling setupOptions().

  6. to list
  7. Open data source for data source name
    DataSource  :: DataSource ( odaba::String &sDataSourceName )

    The data source will be initialized from the option section with the name passed in sDataSourceName. Options must have been initialized before by calling odaba::initializeApplication() or initializeOptions(). The data source name to refer to an option section in the application configuration file or to a valid data source name defined in the data catalog of the application.

    When the data source could not be opened, the function throws an exception. The data source handle remains as initialized data source handle.

    // initialize application and data source

      initializeApplication("c:/temp/myAppl.ini","Test",ConsoleApplication);

      DataSource  ds("TestData"); // open Test data source

        ...                       // do something for Test data source

      ds.open("Sample");          // refill options from Sample section

                                  // or catalog definition

    • sDataSourceName - Data source name

      The name of the data source refers to a section in a configuration or ini-file or to a data source defined in the data catalog defined for the application. Other data source variables are set from the data source definition referred to by the data source name.

  8. to list
  9. Create a data source by options from ini-file
    DataSource  :: DataSource ( odaba::String &sIniFile, odaba::String &sDataSourceName )

    The data source will be initialized from the option section with the name passed in sDataSourceName, which has to refer to an option section in the configuration file passed in sIniFile or to a valid data source name defined in the data catalog of the application

    When the data source could not be opened, the function throws an exception. The data source handle remains as initialized data source handle.

    // calling DataSource ds("c:/temp/myAppl.ini","Test") is a short cut for:

      DataSourceHandle  dsh();

      dsh.initialize("c:/temp/myAppl.ini","Test");

      dsh.open();

    • sIniFile - Path to ini-file location

      The path may contain any type of folder separator ('/' or '\'). Folder separators will be converted according to the conventions of the target system.

      In order to pass no ini-file, an empty string ( String() ) has to be passed.

    • sDataSourceName - Data source name

      The name of the data source refers to a section in a configuration or ini-file or to a data source defined in the data catalog defined for the application. Other data source variables are set from the data source definition referred to by the data source name.

  10. to list