Rogue Wave banner
Previous fileTop of DocumentContentsIndexNext file

3.1 Kinds of Classes

DBTools.h++ provides the classes you need for data manipulation, error handling, creating expressions, connecting to databases, and achieving database portability. As discussed in Chapter 2, DBTools.h++ uses a two-tier architecture. The core library encapsulates database operations and data manipulation, while a database-dependent access library connects to each database to normalize its datatypes.

The core library provides both a standard interface, which shields you from SQL, and an alternative interface called Open SQL, which allows you to directly execute SQL statements. Please see Section 3.1.5.

This chapter summarizes the different kinds of DBTools.h++ classes you can use to write C++ database applications.

3.1.1 Datatypes

DBTools.h++ insulates your applications from the variations in datatypes defined in different databases. Chapter 6 explains in detail how this is done. DBTools.h++ applications work with the primitive C++ datatypes, plus these additional types:

All of these classes are contained in either the DBTools.h++ core library or Tools.h++.

3.1.2 Database Classes

At the heart of DBTools.h++ is a powerful set of classes designed to encapsulate common database objects and operations. All of these classes are contained in the DBTools.h++ core library.

RWDBManager, RWDBDatabase, and RWDBConnection manage database sessions.

RWDBTable, RWDBColumn, RWDBSchema, RWDBRow, and RWDBStoredProc represent the database objects that their names suggest.

RWDBSelector, RWDBUpdater, RWDBInserter and RWDBBulkInserter, and RWDBDeleter correspond to the basic database operations select, update, insert, and delete.

RWDBResult, RWDBReader, RWDBBulkReader, and RWDBCursor are used to process results.

The database classes are explained in detail in Chapter 4, and the bulk read and write classes are explained in Chapter 7. Detailed information for each class is in the Class Reference.

3.1.3 Expression Classes

Class RWDBExpr is a base class for a family of classes used by DBTools.h++ that allow you to program SQL expressions in C++. Instances of these expressions are usually created anonymously. For example, the following fragment instantiates several RWDBExpr objects:

Additional classes in this category include RWDBAssignment, RWDBCriterion, RWDBCollectableExpr, RWDBBoundExpr, and RWDBJoinExpr. Chapter 4 contains more examples of using these classes.

DBTools.h++ also provides an extensible mechanism for defining SQL expressions for your specific needs. The classes RWDBExprFormDefinition, RWDBExprFuncDef{n}, RWDBCritFormDefinition, and RWDBCritFuncDef{n} support this mechanism. They are discussed in the DBTools.h++ Class Reference.

3.1.4 Error Reporting and Tracing Classes

Class RWDBStatus encapsulates the status of an object or operation, and supports the DBTools.h++ error model. The error model itself is described in Chapter 5. Class RWDBTracer is used to provide a runtime trace of your application's activity; its use is documented in the DBTools.h++ Class Reference.

3.1.5 Open SQL Classes

The Open SQL interface contains three classes that give you direct control over the execution of SQL statements and the data that is bound to them. Class RWDBOSql encapsulates an SQL statement and its input and output bindings. Class RWDBTBuffer<T>, a template class, encapsulates buffers of data that can be bound to the SQL statement. Class RWDBMultiRow adds row semantics to collections of RWDBTBuffers. The Open SQL interface is described in detail in Chapter 12 and Chapter 13.

3.1.6 Other DBTools.h++ Classes

Every DBTools.h++ access library contains an instance of a class derived from RWDBPhraseBook, which is a list of SQL phrases in the dialect of a specific database. Instances of class RWDBDatabase use the phrasebook from their respective access libraries. Applications can obtain a reference to an RWDBPhraseBook via the phraseBook() method of RWDBDatabase.

Classes RWDBMemTable and RWDBTPtrMemTable<T,C> provide ways to store relational data in program memory. The former is a standard version that holds RWDBValue types. The latter uses templates that hold user-defined types.

Class RWDBSystemHandle contains all the hooks used by a DBTools.h++ access library to interact with the native database API. Every RWDBConnection instance has a pointer to an RWDBSystemHandle. Applications can get direct access to the underlying database API through a connection's system handle.

Class RWDBEnvironmentHandle lets you set environment variables for specific databases. To do so, an application calls RWDBDatabase:environmentHandle, which returns a pointer to the base class of a family of classes that contain implementation-specific information. Of course, using RWDBEnvironmentHandle can reduce the portability of applications.

The DBTools.h++ Class Reference and the access library guides contain more information on RWDBSystemHandle, RWDBEnvironmentHandle, and the other classes described here.


Previous fileTop of DocumentContentsIndexNext file

©Copyright 2000, Rogue Wave Software, Inc.
Contact Rogue Wave about documentation or support issues.