Logo ROOT   6.18/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__
18typedef void * SQLHENV;
19typedef void * SQLHDBC;
20typedef short SQLRETURN;
21#else
22#ifdef WIN32
23#include "windows.h"
24#endif
25#include <sql.h>
26#endif
27
28class TList;
29
30class TODBCServer : public TSQLServer {
31
32private:
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
44public:
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();
69 const char *ServerInfo();
70
72 Bool_t Commit();
74
75 ClassDef(TODBCServer,0) // Connection to MySQL server
76};
77
78#endif
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
const Bool_t kTRUE
Definition: RtypesCore.h:87
const char Option_t
Definition: RtypesCore.h:62
#define ClassDef(name, id)
Definition: Rtypes.h:326
A doubly linked list.
Definition: TList.h:44
TSQLStatement * Statement(const char *sql, Int_t=100)
Creates ODBC statement for provided query.
Bool_t ExtractErrors(SQLRETURN retcode, const char *method)
Extract errors, produced by last ODBC function call.
TSQLResult * GetTables(const char *dbname, const char *wild=0)
List all tables in the specified database.
static void PrintDrivers()
Print list of ODBC drivers in form: <name> : <options list>
const char * ServerInfo()
Return server info.
static TList * ListData(Bool_t isdrivers)
Produce TList object with list of available ODBC drivers (isdrivers = kTRUE) or data sources (isdrive...
Int_t CreateDataBase(const char *dbname)
Create a database. Returns 0 if successful, non-zero otherwise.
TODBCServer(const char *db, const char *uid, const char *pw)
Open a connection to a ODBC server.
Definition: TODBCServer.cxx:81
void Close(Option_t *opt="")
Close connection to MySQL DB server.
Int_t Shutdown()
Shutdown the database server.
Bool_t EndTransaction(Bool_t commit)
Complete current transaction (commit = kTRUE) or rollback Switches on autocommit mode of ODBC driver.
Int_t DropDataBase(const char *dbname)
Drop (i.e.
TSQLResult * GetDataBases(const char *wild=0)
List all available databases.
virtual ~TODBCServer()
Close connection to MySQL DB server.
SQLHDBC fHdbc
Definition: TODBCServer.h:34
static TList * GetDrivers()
Produce TList object with list of available ODBC drivers User must delete TList object aftewards Name...
TList * GetTablesList(const char *wild=0)
Return list of tables in database See TSQLServer::GetTablesList() for details.
Bool_t StartTransaction()
Starts transaction.
TSQLResult * GetColumns(const char *dbname, const char *table, const char *wild=0)
List all columns in specified table in the specified database.
static void PrintDataSources()
Print list of ODBC data sources in form: <name> : <options list>
Bool_t Rollback()
Rollback transaction.
Bool_t HasStatement() const
Definition: TODBCServer.h:57
static TList * GetDataSources()
Produce TList object with list of available ODBC data sources User must delete TList object aftewards...
Int_t SelectDataBase(const char *dbname)
Select a database.
Int_t Reload()
Reload permission tables.
TSQLTableInfo * GetTableInfo(const char *tablename)
Produces SQL table info Object must be deleted by user.
SQLHENV fHenv
Definition: TODBCServer.h:33
TString fUserId
Definition: TODBCServer.h:36
Bool_t Commit()
Commit transaction.
Int_t GetMaxIdentifierLength()
returns maximum allowed length of identifier (table name, column name, index name)
TString fServerInfo
Definition: TODBCServer.h:35
Bool_t Exec(const char *sql)
Executes query which does not produce any results set Return kTRUE if successfull.
TSQLResult * Query(const char *sql)
Execute SQL command.
Basic string class.
Definition: TString.h:131