Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
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
36  TString fUserId;
37 
38  Bool_t ExtractErrors(SQLRETURN retcode, const char* method);
39 
40  Bool_t EndTransaction(Bool_t commit);
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);
64  Int_t GetMaxIdentifierLength();
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 
71  Bool_t StartTransaction();
72  Bool_t Commit();
73  Bool_t Rollback();
74 
75  ClassDef(TODBCServer,0) // Connection to MySQL server
76 };
77 
78 #endif