ROOT » NET » NET » TSQLServer

class TSQLServer: public TObject


TSQLServer

Abstract base class defining interface to a SQL server.

To open a connection to a server use the static method Connect().
The db argument of Connect() is of the form:
<dbms>://<host>[:<port>][/<database>], e.g.
mysql://pcroot.cern.ch:3456/test, oracle://srv1.cern.ch/main, ...
Depending on the <dbms> specified an appropriate plugin library
will be loaded which will provide the real interface.
For SQLite, the syntax is slightly different:
sqlite://<database>
The string 'database' is directly passed to sqlite3_open(_v2),
so e.g. a filename or ":memory:" are possible values.
For SQLite versions >= 3.7.7, SQLITE_OPEN_URI is activated to also
allow URI-parameters if needed.

Related classes are TSQLResult and TSQLRow.


Function Members (Methods)

 
    This is an abstract class, constructors will not be documented.
    Look at the header to check for available constructors.

public:
virtual~TSQLServer()
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* option = "")
virtual Bool_tCommit()
virtual Int_tTObject::Compare(const TObject* obj) const
static 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 voidEnableErrorOutput(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*GetDB() const
const char*GetDBMS() const
virtual Option_t*TObject::GetDrawOption() const
static Long_tTObject::GetDtorOnly()
virtual Int_tGetErrorCode() const
virtual const char*GetErrorMsg() const
static const char*GetFloatFormat()
const char*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_tGetPort() 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_tHasTable(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_tIsConnected() const
virtual Bool_tTObject::IsEqual(const TObject* obj) const
virtual Bool_tIsError() 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)
TSQLServer&operator=(const TSQLServer&)
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 voidSetFloatFormat(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*, 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
TSQLServer(const TSQLServer&)
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:
voidClearError()
virtual voidTObject::DoError(int level, const char* location, const char* fmt, va_list va) const
voidTObject::MakeZombie()
voidSetError(Int_t code, const char* msg, const char* method = 0)
TSQLServer()

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::ESQLDataTypeskSQL_BINARY
static TSQLServer::ESQLDataTypeskSQL_CHAR
static TSQLServer::ESQLDataTypeskSQL_DOUBLE
static TSQLServer::ESQLDataTypeskSQL_FLOAT
static TSQLServer::ESQLDataTypeskSQL_INTEGER
static TSQLServer::ESQLDataTypeskSQL_NONE
static TSQLServer::ESQLDataTypeskSQL_NUMERIC
static TSQLServer::ESQLDataTypeskSQL_TIMESTAMP
static TSQLServer::ESQLDataTypeskSQL_VARCHAR
static TObject::(anonymous)TObject::kSingleKey
static TObject::(anonymous)TObject::kWriteDelete
static TObject::(anonymous)TObject::kZombie
protected:
TStringfDBcurrently selected DB
Int_tfErrorCodeerror code of last operation
TStringfErrorMsgerror message of last operation
Bool_tfErrorOutenable error output
TStringfHosthost to which we are connected
Int_tfPortport to which we are connected
TStringfTypetype of DBMS (MySQL, Oracle, SysBase, ...)
static const char*fgFloatFmt! printf argument for floats and doubles, either "%f" or "%e" or "%10f" and so on

Class Charts

Inheritance Chart:
TObject
TSQLServer
TMySQLServer

Function documentation

TSQLServer * Connect(const char* db, const char* uid, const char* pw)
 The db should be of the form:  <dbms>://<host>[:<port>][/<database>],
 e.g.:  mysql://pcroot.cern.ch:3456/test, oracle://srv1.cern.ch/main,
 pgsql://... or sapdb://...
 The uid is the username and pw the password that should be used for
 the connection. Depending on the <dbms> the shared library (plugin)
 for the selected system will be loaded. When the connection could not
 be opened 0 is returned.
Bool_t Exec(const char* sql)
 Execute sql query.
 Usefull for commands like DROP TABLE or INSERT, where result set
 is not interested. Return kTRUE if no error
Int_t GetErrorCode() const
 returns error code of last operation
 if res==0, no error
 Each specific implementation of TSQLServer provides its own error coding
const char* GetErrorMsg() const
 returns error message of last operation
 if no errors, return 0
 Each specific implementation of TSQLServer provides its own error messages
void ClearError()
 reset error fields
void SetError(Int_t code, const char* msg, const char* method = 0)
 set new values for error fields
 if method is specified, displays error message
Bool_t StartTransaction()
 submit "START TRANSACTION" query to database
 return kTRUE, if successful
Bool_t Commit()
 submit "COMMIT" query to database
 return kTRUE, if successful
Bool_t Rollback()
 submit "ROLLBACK" query to database
 return kTRUE, if successful
TList* GetTablesList(const char* wild = 0)
 Return list of user tables
 Parameter wild specifies wildcard for table names.
 It either contains exact table name to verify that table is exists or
 wildcard with "%" (any number of symbols) and "_" (exactly one symbol).
 Example of vaild wildcards: "%", "%name","___user__".
 If wild=="", list of all available tables will be produced.
 List contain just tables names in the TObjString.
 List must be deleted by the user.
 Example code of method usage:

 TList* lst = serv->GetTablesList();
 TIter next(lst);
 TObject* obj;
 while (obj = next())
   std::cout << "Table: " << obj->GetName() << std::endl;
 delete lst;
Bool_t HasTable(const char* tablename)
 Tests if table of that name exists in database
 Return kTRUE, if table exists
TSQLTableInfo* GetTableInfo(const char* tablename)
 Producec TSQLTableInfo object, which contain info about
 table itself and each table column
 Object must be deleted by user.
void SetFloatFormat(const char* fmt = "%e")
 set printf format for float/double members, default "%e"
const char* GetFloatFormat()
 return current printf format for float/double members, default "%e"
TSQLServer()
{ ClearError(); }
virtual ~TSQLServer()
{ }
void Close(Option_t* option = "")
TSQLResult * Query(const char* sql)
Bool_t HasStatement() const
{ return kFALSE; }
Int_t SelectDataBase(const char* dbname)
TSQLResult * GetDataBases(const char* wild = 0)
TSQLResult * GetTables(const char* dbname, const char* wild = 0)
TSQLResult * GetColumns(const char* dbname, const char* table, const char* wild = 0)
Int_t GetMaxIdentifierLength()
{ return 20; }
Int_t CreateDataBase(const char* dbname)
Int_t DropDataBase(const char* dbname)
Int_t Reload()
Int_t Shutdown()
const char * ServerInfo()
Bool_t IsConnected() const
{ return fPort == -1 ? kFALSE : kTRUE; }
const char * GetDBMS() const
{ return fType.Data(); }
const char * GetDB() const
{ return fDB.Data(); }
const char * GetHost() const
{ return fHost.Data(); }
Int_t GetPort() const
{ return fPort; }
Bool_t IsError() const
{ return GetErrorCode()!=0; }
void EnableErrorOutput(Bool_t on = kTRUE)
{ fErrorOut = on; }
Bool_t PingVerify()
{ return kFALSE; }
Int_t Ping()
{ return -9999; }