IDb



Describes database manager which handles data sources and connections to them.

In Databases article you may find complete information with examples about working with databases.

You can find more information in comments below. Overrided methods can be found in corresponding base interface.

class IDb :public virtual IReleasable
{
public:
    PlatformHandle const &Handle; // Platform-dependent environment handle 
    DbStatus const &Status; // Manager status 
    IErrorListener* const &ErrorListener; // Assigned error listener 
    bool const &AssignErrorListener; // Whether error listener should be also automatically assigned to created connections 

    virtual DbOdbcVersion getOdbcVersion() = 0; // Return ODBC version which will be used in initialization 
    virtual int getDataSourceCount() = 0; // Return count of found data sources. Works only after successful initialization 
    virtual StringKeyValue getDataSource(const int index) = 0; // Return data source description by index or empty value if index is out of bounds. Works only after successful initialization 
    virtual StringKeyValueArray getDataSources(const bool force = false) = 0; // Return available data sources. Result is cached after the first call. To refresh the cache use force = true. Works only after successful initialization 
    virtual int getDriverCount() = 0; // Return count of found data drivers. Works only after successful initialization 
    virtual StringKeyValue getDriver(const int index) = 0; // Return data driver name by index. Works only after successful initialization 
    virtual StringKeyValueArray getDrivers(const bool force = false) = 0; // Return all found data drivers. Works only after successful initialization 
    virtual int getConnectionCount() = 0; // Return number of created and not yet released connections 
    virtual IDbConnection *getConnection(const int index) = 0; // Return connection by index 

    virtual void setErrorListener(IErrorListener *value) = 0; // Assign new error listener. nullptr value if also accepted 
    virtual bool setAssignErrorListener(const bool value) = 0; // Set whether error listener should or should not be also automatically assigned to all new connections 
    virtual bool setOdbcVersion(const DbOdbcVersion value) = 0; // Set ODBC version to be used at initialization process. Can be called only on uninitialized object 

    // Listeners 
    virtual bool RegisterReleaseListener(IReleasableListener *listener) = 0; // Add release listener used to detect final release of the manager 
    virtual bool UnregisterReleaseListener(IReleasableListener *listener) = 0; // Remove release listener from list 

    // Initialization 
    virtual bool Initialize() = 0; // Try to initialize the manager. If success or it was initialized before, increase reference counter and return true. If fails or failed before do not increase reference counter, just returns false'); ?> 

    // Connection 
    virtual IDbConnection *Connect(const String &connection_options, const bool prompt, IWindow *window = nullptr) = 0; // Connect using connection string 
    virtual IDbConnection *Connect(const String &driver, const String &server = L"", const int port = 0, const String &username = L"", const String &password = L"", const String &database = L"") = 0; // Connect using parameters 
    virtual IDbConnection *ConnectIf(const String &connection_options, const bool prompt, IWindow *window = nullptr) = 0; // Connect using connection string. If connection with the same connection options already exists, increase its reference counter and return that connection instead of creation a new one. If such connection doesn't exist, create a new one 
    virtual IDbConnection *ConnectIf(const String &driver, const String &server = L"", const int port = 0, const String &username = L"", const String &password = L"", const String &database = L"") = 0; // Connect using parameters. If connection with the same connection options already exists, increase its reference counter and return that connection instead of creation a new one. If such connection doesn't exist, create a new one 
};
Namespace: nitisa
Include: Nitisa/Interfaces/IDb.h