Logo ROOT  
Reference Guide
Go to the documentation of this file.
1// @(#)root/odbc:$Id$
2// Author: Sergey Linev 6/02/2006
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 *************************************************************************/
12#ifndef ROOT_TODBCServer
13#define ROOT_TODBCServer
15#include "TSQLServer.h"
17#ifdef __CLING__
18typedef void * SQLHENV;
19typedef void * SQLHDBC;
20typedef short SQLRETURN;
22#ifdef WIN32
23#include "windows.h"
25#include <sql.h>
28class TList;
30class TODBCServer : public TSQLServer {
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
38 Bool_t ExtractErrors(SQLRETURN retcode, const char* method);
42 static TList* ListData(Bool_t isdrivers);
45 TODBCServer(const char* db, const char *uid, const char *pw);
46 virtual ~TODBCServer();
48 static TList* GetDrivers();
49 static void PrintDrivers();
50 static TList* GetDataSources();
51 static void PrintDataSources();
53 void Close(Option_t *opt="") final;
54 TSQLResult *Query(const char *sql) final;
55 Bool_t Exec(const char* sql) final;
56 TSQLStatement *Statement(const char *sql, Int_t = 100) final;
57 Bool_t HasStatement() const final { return kTRUE; }
58 Int_t SelectDataBase(const char *dbname) final;
59 TSQLResult *GetDataBases(const char *wild = nullptr) final;
60 TSQLResult *GetTables(const char *dbname, const char *wild = nullptr) final;
61 TList *GetTablesList(const char* wild = nullptr) final;
62 TSQLTableInfo* GetTableInfo(const char* tablename) final;
63 TSQLResult *GetColumns(const char *dbname, const char *table, const char *wild = nullptr) final;
65 Int_t CreateDataBase(const char *dbname) final;
66 Int_t DropDataBase(const char *dbname) final;
67 Int_t Reload() final;
68 Int_t Shutdown() final;
69 const char *ServerInfo() final;
72 Bool_t Commit() final;
73 Bool_t Rollback() final;
75 ClassDefOverride(TODBCServer,0) // Connection to MySQL server
bool Bool_t
Definition: RtypesCore.h:63
int Int_t
Definition: RtypesCore.h:45
const Bool_t kTRUE
Definition: RtypesCore.h:100
const char Option_t
Definition: RtypesCore.h:66
#define ClassDefOverride(name, id)
Definition: Rtypes.h:339
A doubly linked list.
Definition: TList.h:38
Bool_t ExtractErrors(SQLRETURN retcode, const char *method)
Extract errors, produced by last ODBC function call.
static void PrintDrivers()
Print list of ODBC drivers in form: <name> : <options-list>
TSQLResult * GetTables(const char *dbname, const char *wild=nullptr) final
List all tables in the specified database.
TSQLResult * GetDataBases(const char *wild=nullptr) final
List all available databases.
Int_t Shutdown() final
Shutdown the database server.
static TList * ListData(Bool_t isdrivers)
Produce TList object with list of available ODBC drivers (isdrivers = kTRUE) or data sources (isdrive...
TODBCServer(const char *db, const char *uid, const char *pw)
Open a connection to a ODBC server.
Definition: TODBCServer.cxx:83
TSQLStatement * Statement(const char *sql, Int_t=100) final
Creates ODBC statement for provided query.
Bool_t EndTransaction(Bool_t commit)
Complete current transaction (commit = kTRUE) or rollback Switches on autocommit mode of ODBC driver.
Int_t Reload() final
Reload permission tables.
Bool_t StartTransaction() final
Starts transaction.
Int_t SelectDataBase(const char *dbname) final
Select a database.
virtual ~TODBCServer()
Close connection to MySQL DB server.
void Close(Option_t *opt="") final
Close connection to MySQL DB server.
Int_t GetMaxIdentifierLength() final
returns maximum allowed length of identifier (table name, column name, index name)
TSQLTableInfo * GetTableInfo(const char *tablename) final
Produces SQL table info Object must be deleted by user.
Definition: TODBCServer.h:34
static TList * GetDrivers()
Produce TList object with list of available ODBC drivers User must delete TList object afterwards Nam...
Bool_t Rollback() final
Rollback transaction.
Int_t DropDataBase(const char *dbname) final
Drop (i.e.
static void PrintDataSources()
Print list of ODBC data sources in form: <name> : <options list>
const char * ServerInfo() final
Return server info.
TSQLResult * Query(const char *sql) final
Execute SQL command.
Int_t CreateDataBase(const char *dbname) final
Create a database. Returns 0 if successful, non-zero otherwise.
static TList * GetDataSources()
Produce TList object with list of available ODBC data sources User must delete TList object afterward...
TSQLResult * GetColumns(const char *dbname, const char *table, const char *wild=nullptr) final
List all columns in specified table in the specified database.
TList * GetTablesList(const char *wild=nullptr) final
Return list of tables in database See TSQLServer::GetTablesList() for details.
Bool_t Commit() final
Commit transaction.
Definition: TODBCServer.h:33
TString fUserId
Definition: TODBCServer.h:36
Bool_t Exec(const char *sql) final
Executes query which does not produce any results set Return kTRUE if successful.
TString fServerInfo
Definition: TODBCServer.h:35
Bool_t HasStatement() const final
Definition: TODBCServer.h:57
Basic string class.
Definition: TString.h:136