ROOT  6.06/09
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 #ifndef ROOT_TSQLServer
16 #include "TSQLServer.h"
17 #endif
18 
19 #ifdef __CLING__
20 typedef void * SQLHENV;
21 typedef void * SQLHDBC;
22 typedef short SQLRETURN;
23 #else
24 #ifdef WIN32
25 #include "windows.h"
26 #endif
27 #include <sql.h>
28 #endif
29 
30 class TList;
31 
32 class TODBCServer : public TSQLServer {
33 
34 private:
35  SQLHENV fHenv;
36  SQLHDBC fHdbc;
37  TString fServerInfo; // string with DBMS name and version like MySQL 4.1.11 or Oracle 10.01.0030
39 
40  Bool_t ExtractErrors(SQLRETURN retcode, const char* method);
41 
43 
44  static TList* ListData(Bool_t isdrivers);
45 
46 public:
47  TODBCServer(const char* db, const char *uid, const char *pw);
48  virtual ~TODBCServer();
49 
50  static TList* GetDrivers();
51  static void PrintDrivers();
52  static TList* GetDataSources();
53  static void PrintDataSources();
54 
55  void Close(Option_t *opt="");
56  TSQLResult *Query(const char *sql);
57  Bool_t Exec(const char* sql);
58  TSQLStatement *Statement(const char *sql, Int_t = 100);
59  Bool_t HasStatement() const { return kTRUE; }
60  Int_t SelectDataBase(const char *dbname);
61  TSQLResult *GetDataBases(const char *wild = 0);
62  TSQLResult *GetTables(const char *dbname, const char *wild = 0);
63  TList *GetTablesList(const char* wild = 0);
64  TSQLTableInfo* GetTableInfo(const char* tablename);
65  TSQLResult *GetColumns(const char *dbname, const char *table, const char *wild = 0);
67  Int_t CreateDataBase(const char *dbname);
68  Int_t DropDataBase(const char *dbname);
69  Int_t Reload();
70  Int_t Shutdown();
71  const char *ServerInfo();
72 
74  Bool_t Commit();
75  Bool_t Rollback();
76 
77  ClassDef(TODBCServer,0) // Connection to MySQL server
78 };
79 
80 #endif
Int_t SelectDataBase(const char *dbname)
Select a database.
static void PrintDrivers()
Print list of ODBC drivers in form: : ="">
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:37
TSQLTableInfo * GetTableInfo(const char *tablename)
Produces SQL table info Object must be deleted by user.
Basic string class.
Definition: TString.h:137
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:254
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:47
TList * GetTablesList(const char *wild=0)
Return list of tables in database See TSQLServer::GetTablesList() for details.
SQLHDBC fHdbc
Definition: TODBCServer.h:36
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:38
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:35
Int_t DropDataBase(const char *dbname)
Drop (i.e.
Bool_t Commit()
Commit transaction.
Int_t Reload()
Reload permission tables.
static void PrintDataSources()
Print list of ODBC data sources in form: : ="">
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: Rtypes.h:91
TODBCServer(const char *db, const char *uid, const char *pw)
Bool_t HasStatement() const
Definition: TODBCServer.h:59
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) ...