Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
connection.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file connection.h
1 /*
2  This file is part of libodbc++.
3 
4  Copyright (C) 1999-2000 Manush Dodunekov <manush@stendahls.net>
5 
6  This library is free software; you can redistribute it and/or
7  modify it under the terms of the GNU Library General Public
8  License as published by the Free Software Foundation; either
9  version 2 of the License, or (at your option) any later version.
10 
11  This library is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  Library General Public License for more details.
15 
16  You should have received a copy of the GNU Library General Public License
17  along with this library; see the file COPYING. If not, write to
18  the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19  Boston, MA 02111-1307, USA.
20 */
21 
22 #ifndef __ODBCXX_CONNECTION_H
23 #define __ODBCXX_CONNECTION_H
24 
25 #include <RDBC/odbc++/setup.h>
26 #include <RDBC/odbc++/types.h>
28 
29 namespace odbc {
30 
31  class DriverInfo;
32  class DatabaseMetaData;
33  class Statement;
34  class PreparedStatement;
35  class CallableStatement;
36 
39  friend class DriverManager;
40  friend class Statement;
41  friend class DatabaseMetaData;
42  friend class DriverInfo;
43 
44  private:
45  struct PD;
46  // private data
47  PD* pd_;
48 
49  SQLHDBC hdbc_;
50 
52  DriverInfo* driverInfo_;
53 
54  //utilities
55  SQLUINTEGER _getNumericOption(SQLINTEGER optnum);
56  ODBCXX_STRING _getStringOption(SQLINTEGER optnum);
57  void _setNumericOption(SQLINTEGER optnum, SQLUINTEGER value);
58  void _setStringOption(SQLINTEGER optnum, const ODBCXX_STRING& value);
59 
60  SQLHSTMT _allocStmt();
61 
62  //private constructor, called from DriverManager
63  Connection(SQLHDBC h);
64 
65  void _connect(const ODBCXX_STRING& dsn,
66  const ODBCXX_STRING& user,
67  const ODBCXX_STRING& password);
68 
69  void _connect(const ODBCXX_STRING& connectString);
70 
71  void _registerStatement(Statement* stmt);
72  void _unregisterStatement(Statement* stmt);
73 
74  const DriverInfo* _getDriverInfo() const {
75  return driverInfo_;
76  }
77 
78  public:
91  TRANSACTION_SERIALIZABLE
92  };
93 
95  virtual ~Connection();
96 
98  bool getAutoCommit();
99 
103  void setAutoCommit(bool autoCommit);
104 
106  void commit();
107 
109  void rollback();
110 
112  ODBCXX_STRING getCatalog();
113 
115  void setCatalog(const ODBCXX_STRING& catalog);
116 
118  TransactionIsolation getTransactionIsolation();
119 
121  void setTransactionIsolation(TransactionIsolation isolation);
122 
124  bool isReadOnly();
125 
127  void setReadOnly(bool readOnly);
128 
131  bool getTrace();
132 
134  void setTrace(bool on);
135 
137  ODBCXX_STRING getTraceFile();
138 
140  void setTraceFile(const ODBCXX_STRING& s);
141 
147  DatabaseMetaData* getMetaData();
148 
149 
151  Statement* createStatement();
152 
159  Statement* createStatement(int resultSetType,
160  int resultSetConcurrency);
161 
162 
167  PreparedStatement* prepareStatement(const ODBCXX_STRING& sql);
168 
177  PreparedStatement* prepareStatement(const ODBCXX_STRING& sql,
178  int resultSetType,
179  int resultSetConcurrency);
180 
185  CallableStatement* prepareCall(const ODBCXX_STRING& sql);
186 
195  CallableStatement* prepareCall(const ODBCXX_STRING& sql,
196  int resultSetType,
197  int resultSetConcurrency);
198 
202  ODBCXX_STRING nativeSQL(const ODBCXX_STRING& sql);
203  };
204 
205 
206 
207 }; // namespace odbc
208 
209 
210 #endif // __ODBCXX_CONNECTION_H