libodbc++  0.2.5
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 <odbc++/setup.h>
26 #include <odbc++/types.h>
27 #include <odbc++/errorhandler.h>
28 
29 namespace odbc {
30 
31  class DriverInfo;
32  class DatabaseMetaData;
33  class Statement;
34  class PreparedStatement;
35  class CallableStatement;
36 
38  class ODBCXX_EXPORT Connection : public ErrorHandler {
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 
51  DatabaseMetaData* metaData_;
52  DriverInfo* driverInfo_;
53 
54  //utilities
55  SQLUINTEGER _getUIntegerOption(SQLINTEGER optnum);
56  ODBCXX_STRING _getStringOption(SQLINTEGER optnum);
57  void _setIntegerOption(SQLINTEGER optnum, SQLINTEGER value);
58  void _setUIntegerOption(SQLINTEGER optnum, SQLUINTEGER value);
59  void _setStringOption(SQLINTEGER optnum, const ODBCXX_STRING& value);
60 
61  SQLHSTMT _allocStmt();
62 
63  //private constructor, called from DriverManager
64  Connection(SQLHDBC h);
65 
66  void _connect(const ODBCXX_STRING& dsn,
67  const ODBCXX_STRING& user,
68  const ODBCXX_STRING& password);
69 
70  void _connect(const ODBCXX_STRING& connectString, SQLUSMALLINT drvcompl = SQL_DRIVER_COMPLETE);
71 
72  void _registerStatement(Statement* stmt);
73  void _unregisterStatement(Statement* stmt);
74 
75  const DriverInfo* _getDriverInfo() const {
76  return driverInfo_;
77  }
78 
79  public:
92  TRANSACTION_SERIALIZABLE
93  };
94 
96  virtual ~Connection();
97 
99  bool getAutoCommit();
100 
104  void setAutoCommit(bool autoCommit);
105 
107  void commit();
108 
110  void rollback();
111 
113  ODBCXX_STRING getCatalog();
114 
116  void setCatalog(const ODBCXX_STRING& catalog);
117 
119  TransactionIsolation getTransactionIsolation();
120 
122  void setTransactionIsolation(TransactionIsolation isolation);
123 
125  bool isReadOnly();
126 
128  void setReadOnly(bool readOnly);
129 
132  bool getTrace();
133 
135  void setTrace(bool on);
136 
138  ODBCXX_STRING getTraceFile();
139 
141  void setTraceFile(const ODBCXX_STRING& s);
142 
151  DatabaseMetaData* getMetaData();
152 
153 
159  Statement* createStatement();
160 
171  Statement* createStatement(int resultSetType,
172  int resultSetConcurrency);
173 
174 
183  PreparedStatement* prepareStatement(const ODBCXX_STRING& sql);
184 
197  PreparedStatement* prepareStatement(const ODBCXX_STRING& sql,
198  int resultSetType,
199  int resultSetConcurrency);
200 
209  CallableStatement* prepareCall(const ODBCXX_STRING& sql);
210 
223  CallableStatement* prepareCall(const ODBCXX_STRING& sql,
224  int resultSetType,
225  int resultSetConcurrency);
226 
230  ODBCXX_STRING nativeSQL(const ODBCXX_STRING& sql);
231  };
232 
233 
234 
235 } // namespace odbc
236 
237 
238 #endif // __ODBCXX_CONNECTION_H

Go back to the libodbc++ homepage