#include <ConnectionMT.h>
Definition at line 29 of file ConnectionMT.h.
Public Member Functions | |
ConnectionMT (Driver *drv) | |
This constructor will require an instatiated Driver. | |
ConnectionMT (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. | |
~ConnectionMT () | |
cleanup routine | |
ConnectionMT () | |
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 | 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 command which do not return row information such as INSERT, UPDATE, DELETE, etc. | |
int | execCommand (const StringBuffer &cmd) |
Use this method to execute command 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) |
char * | escapeString (const char *) |
const char * | errorMessage () |
const bool | isConnected () |
Checks to see if the connection is still ok. | |
void | open (const String &datafile) |
Opens a connection to a local (embedded) database engine. | |
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 | |
Mutex | mt |
Friends | |
std::ostream & | operator<< (std::ostream &stream, const Object &s) |
xvr2::SQL::ConnectionMT::ConnectionMT | ( | Driver * | drv | ) |
This constructor will require an instatiated Driver.
xvr2::SQL::ConnectionMT::ConnectionMT | ( | 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::ConnectionMT::~ConnectionMT | ( | ) |
cleanup routine
xvr2::SQL::ConnectionMT::ConnectionMT | ( | ) |
void xvr2::SQL::ConnectionMT::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 from xvr2::SQL::Connection.
void xvr2::SQL::ConnectionMT::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 from xvr2::SQL::Connection.
void xvr2::SQL::ConnectionMT::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 from xvr2::SQL::Connection.
void xvr2::SQL::ConnectionMT::disconnect | ( | ) |
A call to this method will inmediately disconnect you from the backend database.
Reimplemented from xvr2::SQL::Connection.
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 from xvr2::SQL::Connection.
ResultSet* xvr2::SQL::ConnectionMT::query | ( | const StringBuffer & | cmd | ) |
Reimplemented from xvr2::SQL::Connection.
int xvr2::SQL::ConnectionMT::execCommand | ( | const String & | cmd | ) |
Use this method to execute command which do not return row information such as INSERT, UPDATE, DELETE, etc.
The method will return the number of affected rows.
Reimplemented from xvr2::SQL::Connection.
int xvr2::SQL::ConnectionMT::execCommand | ( | const StringBuffer & | cmd | ) |
Use this method to execute command which do not return row information such as INSERT, UPDATE, DELETE, etc.
The method will return the number of affected rows.
Reimplemented from xvr2::SQL::Connection.
void xvr2::SQL::ConnectionMT::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 from xvr2::SQL::Connection.
void xvr2::SQL::ConnectionMT::bulkUploadBegin | ( | const String & | table, | |
const String & | cols, | |||
const String & | _delim | |||
) |
Reimplemented from xvr2::SQL::Connection.
void xvr2::SQL::ConnectionMT::bulkUploadData | ( | const String & | data | ) |
Reimplemented from xvr2::SQL::Connection.
void xvr2::SQL::ConnectionMT::bulkUploadEnd | ( | ) |
Reimplemented from xvr2::SQL::Connection.
Reimplemented from xvr2::SQL::Connection.
char* xvr2::SQL::ConnectionMT::escapeString | ( | const char * | ) |
const char* xvr2::SQL::ConnectionMT::errorMessage | ( | ) |
Reimplemented from xvr2::SQL::Connection.
const bool xvr2::SQL::ConnectionMT::isConnected | ( | ) |
void xvr2::SQL::Connection::open | ( | const String & | datafile | ) | [inherited] |
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. |
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] |
Mutex xvr2::SQL::ConnectionMT::mt [private] |
Definition at line 31 of file ConnectionMT.h.
Driver* xvr2::SQL::Connection::driver [protected, inherited] |
String xvr2::SQL::Connection::_server [protected, inherited] |
Definition at line 39 of file Connection.h.
String xvr2::SQL::Connection::_user [protected, inherited] |
Definition at line 40 of file Connection.h.
String xvr2::SQL::Connection::_password [protected, inherited] |
Definition at line 41 of file Connection.h.
String xvr2::SQL::Connection::_dbname [protected, inherited] |
Definition at line 42 of file Connection.h.
int xvr2::SQL::Connection::_port [protected, inherited] |
Definition at line 43 of file Connection.h.
bool xvr2::SQL::Connection::__connected [protected, inherited] |
Definition at line 44 of file Connection.h.
String* xvr2::SQL::Connection::bulk_delim [protected, inherited] |
Definition at line 45 of file Connection.h.
std::string xvr2::Object::__cls_name [protected, inherited] |