00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef __ODBCXX_CONNECTION_H
00023 #define __ODBCXX_CONNECTION_H
00024
00025 #include <odbc++/setup.h>
00026 #include <odbc++/types.h>
00027 #include <odbc++/errorhandler.h>
00028
00029 namespace odbc {
00030
00031 class DriverInfo;
00032 class DatabaseMetaData;
00033 class Statement;
00034 class PreparedStatement;
00035 class CallableStatement;
00036
00038 class ODBCXX_EXPORT Connection : public ErrorHandler {
00039 friend class DriverManager;
00040 friend class Statement;
00041 friend class DatabaseMetaData;
00042 friend class DriverInfo;
00043
00044 private:
00045 struct PD;
00046
00047 PD* pd_;
00048
00049 SQLHDBC hdbc_;
00050
00051 DatabaseMetaData* metaData_;
00052 DriverInfo* driverInfo_;
00053
00054
00055 SQLUINTEGER _getNumericOption(SQLINTEGER optnum);
00056 ODBCXX_STRING _getStringOption(SQLINTEGER optnum);
00057 void _setNumericOption(SQLINTEGER optnum, SQLUINTEGER value);
00058 void _setStringOption(SQLINTEGER optnum, const ODBCXX_STRING& value);
00059
00060 SQLHSTMT _allocStmt();
00061
00062
00063 Connection(SQLHDBC h);
00064
00065 void _connect(const ODBCXX_STRING& dsn,
00066 const ODBCXX_STRING& user,
00067 const ODBCXX_STRING& password);
00068
00069 void _connect(const ODBCXX_STRING& connectString);
00070
00071 void _registerStatement(Statement* stmt);
00072 void _unregisterStatement(Statement* stmt);
00073
00074 const DriverInfo* _getDriverInfo() const {
00075 return driverInfo_;
00076 }
00077
00078 public:
00081 enum TransactionIsolation {
00083 TRANSACTION_NONE,
00085 TRANSACTION_READ_UNCOMMITTED,
00087 TRANSACTION_READ_COMMITTED,
00089 TRANSACTION_REPEATABLE_READ,
00091 TRANSACTION_SERIALIZABLE
00092 };
00093
00095 virtual ~Connection();
00096
00098 bool getAutoCommit();
00099
00103 void setAutoCommit(bool autoCommit);
00104
00106 void commit();
00107
00109 void rollback();
00110
00112 ODBCXX_STRING getCatalog();
00113
00115 void setCatalog(const ODBCXX_STRING& catalog);
00116
00118 TransactionIsolation getTransactionIsolation();
00119
00121 void setTransactionIsolation(TransactionIsolation isolation);
00122
00124 bool isReadOnly();
00125
00127 void setReadOnly(bool readOnly);
00128
00131 bool getTrace();
00132
00134 void setTrace(bool on);
00135
00137 ODBCXX_STRING getTraceFile();
00138
00140 void setTraceFile(const ODBCXX_STRING& s);
00141
00147 DatabaseMetaData* getMetaData();
00148
00149
00151 Statement* createStatement();
00152
00159 Statement* createStatement(int resultSetType,
00160 int resultSetConcurrency);
00161
00162
00167 PreparedStatement* prepareStatement(const ODBCXX_STRING& sql);
00168
00177 PreparedStatement* prepareStatement(const ODBCXX_STRING& sql,
00178 int resultSetType,
00179 int resultSetConcurrency);
00180
00185 CallableStatement* prepareCall(const ODBCXX_STRING& sql);
00186
00195 CallableStatement* prepareCall(const ODBCXX_STRING& sql,
00196 int resultSetType,
00197 int resultSetConcurrency);
00198
00202 ODBCXX_STRING nativeSQL(const ODBCXX_STRING& sql);
00203 };
00204
00205
00206
00207 };
00208
00209
00210 #endif // __ODBCXX_CONNECTION_H