Logo ROOT   6.14/05
Reference Guide
TODBCServer.h
Go to the documentation of this file.
1 // @(#)root/odbc:$Id$
2 // Author: Sergey Linev 6/02/2006
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2006, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #ifndef ROOT_TODBCServer
13 #define ROOT_TODBCServer
14 
15 #include "TSQLServer.h"
16 
17 #ifdef __CLING__
18 typedef void * SQLHENV;
19 typedef void * SQLHDBC;
20 typedef short SQLRETURN;
21 #else
22 #ifdef WIN32
23 #include "windows.h"
24 #endif
25 #include <sql.h>
26 #endif
27 
28 class TList;
29 
30 class TODBCServer : public TSQLServer {
31 
32 private:
33  SQLHENV fHenv;
34  SQLHDBC fHdbc;
35  TString fServerInfo; // string with DBMS name and version like MySQL 4.1.11 or Oracle 10.01.0030
37 
38  Bool_t ExtractErrors(SQLRETURN retcode, const char* method);
39 
41 
42  static TList* ListData(Bool_t isdrivers);
43 
44 public:
45  TODBCServer(const char* db, const char *uid, const char *pw);
46  virtual ~TODBCServer();
47 
48  static TList* GetDrivers();
49  static void PrintDrivers();
50  static TList* GetDataSources();
51  static void PrintDataSources();
52 
53  void Close(Option_t *opt="");
54  TSQLResult *Query(const char *sql);
55  Bool_t Exec(const char* sql);
56  TSQLStatement *Statement(const char *sql, Int_t = 100);
57  Bool_t HasStatement() const { return kTRUE; }
58  Int_t SelectDataBase(const char *dbname);
59  TSQLResult *GetDataBases(const char *wild = 0);
60  TSQLResult *GetTables(const char *dbname, const char *wild = 0);
61  TList *GetTablesList(const char* wild = 0);
62  TSQLTableInfo* GetTableInfo(const char* tablename);
63  TSQLResult *GetColumns(const char *dbname, const char *table, const char *wild = 0);
65  Int_t CreateDataBase(const char *dbname);
66  Int_t DropDataBase(const char *dbname);
67  Int_t Reload();
68  Int_t Shutdown();
69  const char *ServerInfo();
70 
72  Bool_t Commit();
73  Bool_t Rollback();
74 
75  ClassDef(TODBCServer,0) // Connection to MySQL server
76 };
77 
78 #endif
Int_t SelectDataBase(const char *dbname)
Select a database.
static void PrintDrivers()
Print list of ODBC drivers in form: <name> : <options list>="">
static TList * ListData(Bool_t isdrivers)
Produce TList object with list of available ODBC drivers (isdrivers = kTRUE) or data sources (isdrive...
const char Option_t
Definition: RtypesCore.h:62
Bool_t EndTransaction(Bool_t commit)
Complete current transaction (commit = kTRUE) or rollback Switches on autocommit mode of ODBC driver...
TSQLResult * Query(const char *sql)
Execute SQL command.
TString fServerInfo
Definition: TODBCServer.h:35
TSQLTableInfo * GetTableInfo(const char *tablename)
Produces SQL table info Object must be deleted by user.
Basic string class.
Definition: TString.h:131
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
Bool_t Exec(const char *sql)
Executes query which does not produce any results set Return kTRUE if successfull.
void Close(Option_t *opt="")
Close connection to MySQL DB server.
#define ClassDef(name, id)
Definition: Rtypes.h:320
static TList * GetDataSources()
Produce TList object with list of available ODBC data sources User must delete TList object aftewards...
A doubly linked list.
Definition: TList.h:44
TList * GetTablesList(const char *wild=0)
Return list of tables in database See TSQLServer::GetTablesList() for details.
SQLHDBC fHdbc
Definition: TODBCServer.h:34
Bool_t ExtractErrors(SQLRETURN retcode, const char *method)
Extract errors, produced by last ODBC function call.
static TList * GetDrivers()
Produce TList object with list of available ODBC drivers User must delete TList object aftewards Name...
TSQLStatement * Statement(const char *sql, Int_t=100)
Creates ODBC statement for provided query.
Bool_t StartTransaction()
Starts transaction.
TString fUserId
Definition: TODBCServer.h:36
Int_t Shutdown()
Shutdown the database server.
TSQLResult * GetTables(const char *dbname, const char *wild=0)
List all tables in the specified database.
SQLHENV fHenv
Definition: TODBCServer.h:33
Int_t DropDataBase(const char *dbname)
Drop (i.e.
Bool_t Commit()
Commit transaction.
Int_t Reload()
Reload permission tables.
Bool_t HasStatement() const
Definition: TODBCServer.h:57
static void PrintDataSources()
Print list of ODBC data sources in form: <name> : <options list>="">
const char * ServerInfo()
Return server info.
TSQLResult * GetDataBases(const char *wild=0)
List all available databases.
virtual ~TODBCServer()
Close connection to MySQL DB server.
Bool_t Rollback()
Rollback transaction.
const Bool_t kTRUE
Definition: RtypesCore.h:87
TODBCServer(const char *db, const char *uid, const char *pw)
Open a connection to a ODBC server.
Definition: TODBCServer.cxx:81
Int_t CreateDataBase(const char *dbname)
Create a database. Returns 0 if successful, non-zero otherwise.
TSQLResult * GetColumns(const char *dbname, const char *table, const char *wild=0)
List all columns in specified table in the specified database.
Int_t GetMaxIdentifierLength()
returns maximum allowed length of identifier (table name, column name, index name) ...