ROOT » SQL » MYSQL » TMySQLServer

class TMySQLServer: public TSQLServer


TMySQLServer

MySQL server plugin implementing the TSQLServer interface.

To open a connection to a server use the static method Connect().
The db argument of Connect() is of the form:
mysql://<host>[:<port>][/<database>], e.g.
mysql://pcroot.cern.ch:3456/test

As an example of connecting to mysql we assume that the server is
running on the local host and that you have access to a database
named "test" by connecting using an account that has a username and
password of "tuser" and "tpass". You can set up this account
by using the "mysql" program to connect to the server as the MySQL
root user and issuing the following statement:

 mysql> GRANT ALL ON test.* TO 'tuser'@'localhost' IDENTIFIED BY 'tpass';

If the test database does not exist, create it with this statement:

mysql> CREATE DATABASE test;

If you want to use a different server host, username, password,
or database name, just substitute the appropriate values.
To connect do:

 TSQLServer *db = TSQLServer::Connect("mysql://localhost/test", "tuser", "tpass");


Function Members (Methods)

public:
virtual~TMySQLServer()
voidTObject::AbstractMethod(const char* method) const
virtual voidTObject::AppendPad(Option_t* option = "")
virtual voidTObject::Browse(TBrowser* b)
static TClass*Class()
virtual const char*TObject::ClassName() const
virtual voidTObject::Clear(Option_t* = "")
virtual TObject*TObject::Clone(const char* newname = "") const
virtual voidClose(Option_t* opt = "")
virtual Bool_tCommit()
virtual Int_tTObject::Compare(const TObject* obj) const
static TSQLServer*TSQLServer::Connect(const char* db, const char* uid, const char* pw)
virtual voidTObject::Copy(TObject& object) const
virtual Int_tCreateDataBase(const char* dbname)
virtual voidTObject::Delete(Option_t* option = "")MENU
virtual Int_tTObject::DistancetoPrimitive(Int_t px, Int_t py)
virtual voidTObject::Draw(Option_t* option = "")
virtual voidTObject::DrawClass() constMENU
virtual TObject*TObject::DrawClone(Option_t* option = "") constMENU
virtual Int_tDropDataBase(const char* dbname)
virtual voidTObject::Dump() constMENU
virtual voidTSQLServer::EnableErrorOutput(Bool_t on = kTRUE)
virtual voidTObject::Error(const char* method, const char* msgfmt) const
virtual Bool_tExec(const char* sql)
virtual voidTObject::Execute(const char* method, const char* params, Int_t* error = 0)
virtual voidTObject::Execute(TMethod* method, TObjArray* params, Int_t* error = 0)
virtual voidTObject::ExecuteEvent(Int_t event, Int_t px, Int_t py)
virtual voidTObject::Fatal(const char* method, const char* msgfmt) const
virtual TObject*TObject::FindObject(const char* name) const
virtual TObject*TObject::FindObject(const TObject* obj) const
virtual TSQLResult*GetColumns(const char* dbname, const char* table, const char* wild = 0)
virtual TSQLResult*GetDataBases(const char* wild = 0)
const char*TSQLServer::GetDB() const
const char*TSQLServer::GetDBMS() const
virtual Option_t*TObject::GetDrawOption() const
static Long_tTObject::GetDtorOnly()
virtual Int_tTSQLServer::GetErrorCode() const
virtual const char*TSQLServer::GetErrorMsg() const
static const char*TSQLServer::GetFloatFormat()
const char*TSQLServer::GetHost() const
virtual const char*TObject::GetIconName() const
virtual Int_tGetMaxIdentifierLength()
virtual const char*TObject::GetName() const
virtual char*TObject::GetObjectInfo(Int_t px, Int_t py) const
static Bool_tTObject::GetObjectStat()
virtual Option_t*TObject::GetOption() const
Int_tTSQLServer::GetPort() const
virtual TSQLTableInfo*GetTableInfo(const char* tablename)
virtual TSQLResult*GetTables(const char* dbname, const char* wild = 0)
virtual TList*GetTablesList(const char* wild = 0)
virtual const char*TObject::GetTitle() const
virtual UInt_tTObject::GetUniqueID() const
virtual Bool_tTObject::HandleTimer(TTimer* timer)
virtual ULong_tTObject::Hash() const
virtual Bool_tHasStatement() const
virtual Bool_tTSQLServer::HasTable(const char* tablename)
virtual voidTObject::Info(const char* method, const char* msgfmt) const
virtual Bool_tTObject::InheritsFrom(const char* classname) const
virtual Bool_tTObject::InheritsFrom(const TClass* cl) const
virtual voidTObject::Inspect() constMENU
voidTObject::InvertBit(UInt_t f)
virtual TClass*IsA() const
virtual Bool_tTSQLServer::IsConnected() const
virtual Bool_tTObject::IsEqual(const TObject* obj) const
virtual Bool_tTSQLServer::IsError() const
virtual Bool_tTObject::IsFolder() const
Bool_tTObject::IsOnHeap() const
virtual Bool_tTObject::IsSortable() const
Bool_tTObject::IsZombie() const
virtual voidTObject::ls(Option_t* option = "") const
voidTObject::MayNotUse(const char* method) const
virtual Bool_tTObject::Notify()
voidTObject::Obsolete(const char* method, const char* asOfVers, const char* removedFromVers) const
voidTObject::operator delete(void* ptr)
voidTObject::operator delete(void* ptr, void* vp)
voidTObject::operator delete[](void* ptr)
voidTObject::operator delete[](void* ptr, void* vp)
void*TObject::operator new(size_t sz)
void*TObject::operator new(size_t sz, void* vp)
void*TObject::operator new[](size_t sz)
void*TObject::operator new[](size_t sz, void* vp)
TMySQLServer&operator=(const TMySQLServer&)
virtual voidTObject::Paint(Option_t* option = "")
virtual Int_tPing()
virtual Bool_tPingVerify()
virtual voidTObject::Pop()
virtual voidTObject::Print(Option_t* option = "") const
virtual TSQLResult*Query(const char* sql)
virtual Int_tTObject::Read(const char* name)
virtual voidTObject::RecursiveRemove(TObject* obj)
virtual Int_tReload()
voidTObject::ResetBit(UInt_t f)
virtual Bool_tRollback()
virtual voidTObject::SaveAs(const char* filename = "", Option_t* option = "") constMENU
virtual voidTObject::SavePrimitive(ostream& out, Option_t* option = "")
virtual Int_tSelectDataBase(const char* dbname)
virtual const char*ServerInfo()
voidTObject::SetBit(UInt_t f)
voidTObject::SetBit(UInt_t f, Bool_t set)
virtual voidTObject::SetDrawOption(Option_t* option = "")MENU
static voidTObject::SetDtorOnly(void* obj)
static voidTSQLServer::SetFloatFormat(const char* fmt = "%e")
static voidTObject::SetObjectStat(Bool_t stat)
virtual voidTObject::SetUniqueID(UInt_t uid)
virtual voidShowMembers(TMemberInspector& insp) const
virtual Int_tShutdown()
virtual Bool_tStartTransaction()
virtual TSQLStatement*Statement(const char* sql, Int_t = 100)
virtual voidStreamer(TBuffer&)
voidStreamerNVirtual(TBuffer& ClassDef_StreamerNVirtual_b)
virtual voidTObject::SysError(const char* method, const char* msgfmt) const
Bool_tTObject::TestBit(UInt_t f) const
Int_tTObject::TestBits(UInt_t f) const
TMySQLServer(const TMySQLServer&)
TMySQLServer(const char* db, const char* uid, const char* pw)
virtual voidTObject::UseCurrentStyle()
virtual voidTObject::Warning(const char* method, const char* msgfmt) const
virtual Int_tTObject::Write(const char* name = 0, Int_t option = 0, Int_t bufsize = 0)
virtual Int_tTObject::Write(const char* name = 0, Int_t option = 0, Int_t bufsize = 0) const
protected:
voidTSQLServer::ClearError()
virtual voidTObject::DoError(int level, const char* location, const char* fmt, va_list va) const
voidTObject::MakeZombie()
voidTSQLServer::SetError(Int_t code, const char* msg, const char* method = 0)

Data Members

public:
static TObject::(anonymous)TObject::kBitMask
static TObject::EStatusBitsTObject::kCanDelete
static TObject::EStatusBitsTObject::kCannotPick
static TObject::EStatusBitsTObject::kHasUUID
static TObject::EStatusBitsTObject::kInvalidObject
static TObject::(anonymous)TObject::kIsOnHeap
static TObject::EStatusBitsTObject::kIsReferenced
static TObject::EStatusBitsTObject::kMustCleanup
static TObject::EStatusBitsTObject::kNoContextMenu
static TObject::(anonymous)TObject::kNotDeleted
static TObject::EStatusBitsTObject::kObjInCanvas
static TObject::(anonymous)TObject::kOverwrite
static TSQLServer::ESQLDataTypesTSQLServer::kSQL_BINARY
static TSQLServer::ESQLDataTypesTSQLServer::kSQL_CHAR
static TSQLServer::ESQLDataTypesTSQLServer::kSQL_DOUBLE
static TSQLServer::ESQLDataTypesTSQLServer::kSQL_FLOAT
static TSQLServer::ESQLDataTypesTSQLServer::kSQL_INTEGER
static TSQLServer::ESQLDataTypesTSQLServer::kSQL_NONE
static TSQLServer::ESQLDataTypesTSQLServer::kSQL_NUMERIC
static TSQLServer::ESQLDataTypesTSQLServer::kSQL_TIMESTAMP
static TSQLServer::ESQLDataTypesTSQLServer::kSQL_VARCHAR
static TObject::(anonymous)TObject::kSingleKey
static TObject::(anonymous)TObject::kWriteDelete
static TObject::(anonymous)TObject::kZombie
protected:
TStringTSQLServer::fDBcurrently selected DB
Int_tTSQLServer::fErrorCodeerror code of last operation
TStringTSQLServer::fErrorMsgerror message of last operation
Bool_tTSQLServer::fErrorOutenable error output
TStringTSQLServer::fHosthost to which we are connected
TStringfInfoserver info string
MYSQL*fMySQLconnection to MySQL server
Int_tTSQLServer::fPortport to which we are connected
TStringTSQLServer::fTypetype of DBMS (MySQL, Oracle, SysBase, ...)
static const char*TSQLServer::fgFloatFmt! printf argument for floats and doubles, either "%f" or "%e" or "%10f" and so on

Class Charts

Inheritance Inherited Members Includes Libraries
Class Charts

Function documentation

TMySQLServer(const char* db, const char* uid, const char* pw)
 Open a connection to a MySQL DB server. The db arguments should be
 of the form "mysql://<host>[:<port>][/<database>]", e.g.:
 "mysql://pcroot.cern.ch:3456/test". The uid is the username and pw
 the password that should be used for the connection.

 In addition, several parameters can be specified in url after "?" symbol:
    timeout=N           n is connect timeout is seconds
    socket=socketname   socketname should be name of Unix socket, used
                        for connection
    multi_statements    tell the server that the client may send multiple
                        statements in a single string (separated by ;);
    multi_results       tell the server that the client can handle multiple
                        result sets from multiple-statement executions or
                        stored procedures
    reconnect=0|1       enable or disable automatic reconnection to the server
                        if the connection is found to have been lost
    compress            use the compressed client/server protocol
    cnf_file=filename   Read options from the named option file instead of
                        from my.cnf
    cnf_group=groupname Read options from the named group from my.cnf or the
                        file specified with cnf_file option
 If several parameters are specified, they should be separated by "&" symbol
 Example of connection argument:
    TSQLServer::Connect("mysql://host.domain/test?timeout=10&multi_statements");
~TMySQLServer()
 Close connection to MySQL DB server.
void Close(Option_t* opt = "")
 Close connection to MySQL DB server.
TSQLResult * Query(const char* sql)
 Execute SQL command. Result object must be deleted by the user.
 Returns a pointer to a TSQLResult object if successful, 0 otherwise.
 The result object must be deleted by the user.
Bool_t Exec(const char* sql)
 Execute SQL command which does not produce any result sets.
 Returns kTRUE if successful.
Int_t SelectDataBase(const char* dbname)
 Select a database. Returns 0 if successful, non-zero otherwise.
TSQLResult * GetDataBases(const char* wild = 0)
 List all available databases. Wild is for wildcarding "t%" list all
 databases starting with "t".
 Returns a pointer to a TSQLResult object if successful, 0 otherwise.
 The result object must be deleted by the user.
TSQLResult * GetTables(const char* dbname, const char* wild = 0)
 List all tables in the specified database. Wild is for wildcarding
 "t%" list all tables starting with "t".
 Returns a pointer to a TSQLResult object if successful, 0 otherwise.
 The result object must be deleted by the user.
TList* GetTablesList(const char* wild = 0)
 Return list of tables with specified wildcard.
TSQLTableInfo * GetTableInfo(const char* tablename)
 Produces SQL table info.
 Object must be deleted by user.
TSQLResult * GetColumns(const char* dbname, const char* table, const char* wild = 0)
 List all columns in specified table in the specified database.
 Wild is for wildcarding "t%" list all columns starting with "t".
 Returns a pointer to a TSQLResult object if successful, 0 otherwise.
 The result object must be deleted by the user.
Int_t CreateDataBase(const char* dbname)
 Create a database. Returns 0 if successful, non-zero otherwise.
Int_t DropDataBase(const char* dbname)
 Drop (i.e. delete) a database. Returns 0 if successful, non-zero
 otherwise.
Int_t Reload()
 Reload permission tables. Returns 0 if successful, non-zero
 otherwise. User must have reload permissions.
Int_t Shutdown()
 Shutdown the database server. Returns 0 if successful, non-zero
 otherwise. User must have shutdown permissions.
const char * ServerInfo()
 Return server info in form "MySQL <vesrion>".
Bool_t HasStatement() const
 Return kTRUE if TSQLStatement class is supported.
 Starts from MySQL 4.1.
TSQLStatement * Statement(const char* sql, Int_t = 100)
 Produce TMySQLStatement.
Bool_t StartTransaction()
 Start transaction
Bool_t Commit()
 Commit changes
Bool_t Rollback()
 Rollback changes
Bool_t PingVerify()
 Execute Ping to SQL Connection.
 Since mysql_ping tries to reconnect by itself,
 a double call to the mysql function is implemented.
 Returns kTRUE if successful
Int_t Ping()
 Execute Ping to SQL Connection using the mysql_ping function.
 Returns 0 if successful, non-zero in case an error occured.
TMySQLServer(const char* db, const char* uid, const char* pw)
Int_t GetMaxIdentifierLength()
{ return 64; }