#include <Connection.h>
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. | |
ResultSet * | 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. | |
ResultSet * | query (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 | |
Driver * | driver |
Current driver in use by this Connection instance. | |
String | _server |
String | _user |
String | _password |
String | _dbname |
int | _port |
bool | __connected |
String * | bulk_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) |
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 | ( | ) |
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.
datafile | A path to the datafile to the opened. |
void xvr2::SQL::Connection::disconnect | ( | ) |
A call to this method will inmediately disconnect you from the backend database.
Reimplemented in xvr2::SQL::ConnectionMT.
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.
Reimplemented in xvr2::SQL::ConnectionMT.
const char* xvr2::SQL::Connection::errorMessage | ( | ) |
Reimplemented in xvr2::SQL::ConnectionMT.
const bool xvr2::SQL::Connection::isConnected | ( | ) |
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] |
std::ostream& operator<< | ( | std::ostream & | stream, | |
const Object & | s | |||
) | [friend, inherited] |
void* xvr2::SQL::Connection::__conn [private] |
Driver* xvr2::SQL::Connection::driver [protected] |
String xvr2::SQL::Connection::_server [protected] |
Definition at line 39 of file Connection.h.
String xvr2::SQL::Connection::_user [protected] |
Definition at line 40 of file Connection.h.
String xvr2::SQL::Connection::_password [protected] |
Definition at line 41 of file Connection.h.
String xvr2::SQL::Connection::_dbname [protected] |
Definition at line 42 of file Connection.h.
int xvr2::SQL::Connection::_port [protected] |
Definition at line 43 of file Connection.h.
bool xvr2::SQL::Connection::__connected [protected] |
Definition at line 44 of file Connection.h.
String* xvr2::SQL::Connection::bulk_delim [protected] |
Definition at line 45 of file Connection.h.
std::string xvr2::Object::__cls_name [protected, inherited] |