Main Page | Namespace List | Class Hierarchy | Class List | File List | Class Members | Related Pages | Examples

SimpleDB::Database Class Reference

This class represents a database connection. More...

#include <Database.h>

List of all members.

Public Member Functions

 Database (std::string dsn)
 Constructor creates the database connection.
Query newQuery () const
 Creates a query object for this database.
void voidQuery (const std::string &query) const
 void Query, query the database and don't worry about return types or if its a successful query.
long intQuery (const std::string &query) const
 long Query, query the database for a single integer result.
std::string strQuery (const std::string &query, long bufSize=1000) const
 A Query interface that returns a string result.
const SQLHDBC getConnectionHandle () const
 Function to retrieve the database connection handle.
virtual ~Database ()
 Destructor.

Static Public Member Functions

static const std::string escapeString (const std::string &input)
 Escapes special characters in a string to be sent as part of a database query.
static const std::string boolToStr (const bool in)
 Converts a boolean input to the equivalent database value.

Protected Attributes

SQLHDBC connectionHandle
 ODBC connection handle.
SQLHENV odbc_environment_handle
 ODBC environment handle.

Classes

class  Exception
 This class is thrown in case of any database exception. More...
class  NoDataException
 Exception class thrown when no data is available. More...


Detailed Description

This class represents a database connection.

Todo:
: Overload the default assignment operator so that database objects can be assigned without causing problems with connection handles
Examples:

complete.cpp, and simple.cpp.


Constructor & Destructor Documentation

Database::Database std::string  dsn  ) 
 

Constructor creates the database connection.

Parameters:
dsn The ODBC data source to connect to.


Member Function Documentation

const std::string Database::boolToStr const bool  in  )  [static]
 

Converts a boolean input to the equivalent database value.

Parameters:
in The boolean to convert
Returns:
the converted string.

const std::string Database::escapeString const std::string &  input  )  [static]
 

Escapes special characters in a string to be sent as part of a database query.

Parameters:
input The input string to be escaped.
Returns:
The escaped version of the input string.

const SQLHDBC Database::getConnectionHandle  )  const
 

Function to retrieve the database connection handle.

Returns:
The database connection handle.

long Database::intQuery const std::string &  query  )  const
 

long Query, query the database for a single integer result.

Exceptions:
SimpleDB::Database::Exception Thrown if error with syntax etc.
SimpleDB::Database::NoDataException Thrown if now rows are returned by the query.
Parameters:
query the query to execute
Returns:
the integer result from the query

Query Database::newQuery  )  const
 

Creates a query object for this database.

Returns:
Query The new query object.
Examples:
complete.cpp, and simple.cpp.

std::string Database::strQuery const std::string &  query,
long  bufSize = 1000
const
 

A Query interface that returns a string result.

Parameters:
query The query to execute.
bufSize The max size of the string buffer expected to be returned.
Returns:
resultant string of the query.

void Database::voidQuery const std::string &  query  )  const
 

void Query, query the database and don't worry about return types or if its a successful query.

Parameters:
query The query to execute.


Member Data Documentation

SQLHENV SimpleDB::Database::odbc_environment_handle [protected]
 

ODBC environment handle.

This handle is created by the constructor and freed in the destructor.


The documentation for this class was generated from the following files:
Copyright (C) 2005 Eminence Technology Pty Ltd.
Documentation pages generated by doxygen.

SourceForge.net Logo