xvr2::SQL::Connection Class Reference

#include <Connection.h>

Inheritance diagram for xvr2::SQL::Connection:

Inheritance graph
[legend]

List of all members.


Detailed Description

Handles SQL database connections for RDBMS and embedded engines.

Tipically you'll get a Connection object after you have an instatiated driver, by the time you have the Connection object instatiated you'll still need to perform the database connection (if its an RDBMS) or opening (if it is an embbeded db engine), then after successfull usage you'll disconnect or close the connection itself.

Definition at line 32 of file Connection.h.


Public Member Functions

 Connection (Driver *drv)
 This constructor will require an instatiated Driver.
 Connection (Driver *drv, const String &server, const String &dbname, const String &u, const String &p, int port=0)
 This constructor will initialize the internal driver also will attempt to make a connection to the backend database as soon as possible.
 ~Connection ()
 cleanup routine
 Connection ()
void connect (const String &server, const String &u, const String &dbname, const String &p, int port=0)
 This routine will connect you to the specified server using the username u, password p and port port.
void connect (Driver *d, const String &server, const String &u, const String &dbname, const String &p, int port=0)
 This routine will connect you to the specified server using the username u, password p and port port.
void connect ()
 This method will attempt to connect using the last username, server, password and port supplied in a call connect or the one used in the constructor.
void open (const String &datafile)
 Opens a connection to a local (embedded) database engine.
void disconnect ()
 A call to this method will inmediately disconnect you from the backend database.
ResultSetquery (const String &cmd)
 This method will send the command cmd to the backend database, if it is a select it will return a ResultSet containing the data returned by the database.
ResultSetquery (const StringBuffer &cmd)
int execCommand (const String &cmd)
 Use this method to execute commands which do not return row information such as INSERT, UPDATE, DELETE, etc.
int execCommand (const StringBuffer &cmd)
 Use this method to execute commands which do not return row information such as INSERT, UPDATE, DELETE, etc.
void commit ()
 This will commit any transaction based command to the database, when you call commit every submitted delete or update they will execute each other in sequence.
void bulkUploadBegin (const String &table, const String &cols, const String &_delim)
void bulkUploadData (const String &data)
void bulkUploadEnd ()
String escapeString (const String &s)
const char * errorMessage ()
const bool isConnected ()
 Checks to see if the connection is still ok.
virtual const char * getClassName ()
 Returns the name of the current class.
virtual std::string toString ()

Static Public Member Functions

static void debugmsg (Object *obj, const char *msg, int linenumber=__LINE__, const char *srcfile=__FILE__)
 Will print a debug message to the screen.
static void debugmsgln (Object *obj, const char *msg, int linenumber=__LINE__, const char *srcfile=__FILE__)

Protected Attributes

Driverdriver
 Current driver in use by this Connection instance.
String _server
String _user
String _password
String _dbname
int _port
bool __connected
Stringbulk_delim
std::string __cls_name

Private Attributes

void * __conn
 Opaque pointer to the "real" connection object.

Friends

std::ostream & operator<< (std::ostream &stream, const Object &s)

Constructor & Destructor Documentation

xvr2::SQL::Connection::Connection ( Driver drv  ) 

This constructor will require an instatiated Driver.

xvr2::SQL::Connection::Connection ( Driver drv,
const String server,
const String dbname,
const String u,
const String p,
int  port = 0 
)

This constructor will initialize the internal driver also will attempt to make a connection to the backend database as soon as possible.

xvr2::SQL::Connection::~Connection (  ) 

cleanup routine

xvr2::SQL::Connection::Connection (  ) 


Member Function Documentation

void xvr2::SQL::Connection::connect ( const String server,
const String u,
const String dbname,
const String p,
int  port = 0 
)

This routine will connect you to the specified server using the username u, password p and port port.

If the connection is not successfull this method will throw an appropiate exception.

Reimplemented in xvr2::SQL::ConnectionMT.

void xvr2::SQL::Connection::connect ( Driver d,
const String server,
const String u,
const String dbname,
const String p,
int  port = 0 
)

This routine will connect you to the specified server using the username u, password p and port port.

If the connection is not successfull this method will throw an appropiate exception.

Reimplemented in xvr2::SQL::ConnectionMT.

void xvr2::SQL::Connection::connect (  ) 

This method will attempt to connect using the last username, server, password and port supplied in a call connect or the one used in the constructor.

Reimplemented in xvr2::SQL::ConnectionMT.

void xvr2::SQL::Connection::open ( const String datafile  ) 

Opens a connection to a local (embedded) database engine.

Driver supplied database connection function, this method will attempt to open a datafile as if it was a networked connection, this is very useful for embedded database engines which implement the SQL query language.

Parameters:
datafile A path to the datafile to the opened.
Returns:
A connection handler.

void xvr2::SQL::Connection::disconnect (  ) 

A call to this method will inmediately disconnect you from the backend database.

Reimplemented in xvr2::SQL::ConnectionMT.

ResultSet* xvr2::SQL::Connection::query ( const String cmd  ) 

This method will send the command cmd to the backend database, if it is a select it will return a ResultSet containing the data returned by the database.

If it is another type of command like an update or delete or any other that does not return data or a status completion of success or failure then the returned ResultSet will not contain any data instead call the status method of the ResultSet to know if the call succeeded or not

Reimplemented in xvr2::SQL::ConnectionMT.

ResultSet* xvr2::SQL::Connection::query ( const StringBuffer cmd  ) 

Reimplemented in xvr2::SQL::ConnectionMT.

int xvr2::SQL::Connection::execCommand ( const String cmd  ) 

Use this method to execute commands which do not return row information such as INSERT, UPDATE, DELETE, etc.

The method will only return the number of affected rows.

Reimplemented in xvr2::SQL::ConnectionMT.

int xvr2::SQL::Connection::execCommand ( const StringBuffer cmd  ) 

Use this method to execute commands which do not return row information such as INSERT, UPDATE, DELETE, etc.

The method will only return the number of affected rows.

Reimplemented in xvr2::SQL::ConnectionMT.

void xvr2::SQL::Connection::commit (  ) 

This will commit any transaction based command to the database, when you call commit every submitted delete or update they will execute each other in sequence.

Reimplemented in xvr2::SQL::ConnectionMT.

void xvr2::SQL::Connection::bulkUploadBegin ( const String table,
const String cols,
const String _delim 
)

Reimplemented in xvr2::SQL::ConnectionMT.

void xvr2::SQL::Connection::bulkUploadData ( const String data  ) 

Reimplemented in xvr2::SQL::ConnectionMT.

void xvr2::SQL::Connection::bulkUploadEnd (  ) 

Reimplemented in xvr2::SQL::ConnectionMT.

String xvr2::SQL::Connection::escapeString ( const String s  ) 

Reimplemented in xvr2::SQL::ConnectionMT.

const char* xvr2::SQL::Connection::errorMessage (  ) 

Reimplemented in xvr2::SQL::ConnectionMT.

const bool xvr2::SQL::Connection::isConnected (  ) 

Checks to see if the connection is still ok.

Reimplemented in xvr2::SQL::ConnectionMT.

virtual const char* xvr2::Object::getClassName (  )  [virtual, inherited]

Returns the name of the current class.

static void xvr2::Object::debugmsg ( Object obj,
const char *  msg,
int  linenumber = __LINE__,
const char *  srcfile = __FILE__ 
) [static, inherited]

Will print a debug message to the screen.

static void xvr2::Object::debugmsgln ( Object obj,
const char *  msg,
int  linenumber = __LINE__,
const char *  srcfile = __FILE__ 
) [static, inherited]

virtual std::string xvr2::Object::toString (  )  [virtual, inherited]


Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  stream,
const Object s 
) [friend, inherited]


Member Data Documentation

Opaque pointer to the "real" connection object.

Definition at line 35 of file Connection.h.

Current driver in use by this Connection instance.

Definition at line 38 of file Connection.h.

Definition at line 39 of file Connection.h.

Definition at line 40 of file Connection.h.

Definition at line 41 of file Connection.h.

Definition at line 42 of file Connection.h.

Definition at line 43 of file Connection.h.

Definition at line 44 of file Connection.h.

Definition at line 45 of file Connection.h.

std::string xvr2::Object::__cls_name [protected, inherited]

Definition at line 30 of file Object.h.


The documentation for this class was generated from the following file:

Generated on Fri Jun 20 22:56:04 2008 for X-VR2 SDK by  doxygen 1.5.5