Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members  

odbc++/connection.h

00001 /* 
00002    This file is part of libodbc++.
00003    
00004    Copyright (C) 1999-2000 Manush Dodunekov <manush@stendahls.net>
00005    
00006    This library is free software; you can redistribute it and/or
00007    modify it under the terms of the GNU Library General Public
00008    License as published by the Free Software Foundation; either
00009    version 2 of the License, or (at your option) any later version.
00010    
00011    This library is distributed in the hope that it will be useful,
00012    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014    Library General Public License for more details.
00015    
00016    You should have received a copy of the GNU Library General Public License
00017    along with this library; see the file COPYING.  If not, write to
00018    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00019    Boston, MA 02111-1307, USA.
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     // private data
00047     PD* pd_;
00048 
00049     SQLHDBC hdbc_;
00050 
00051     DatabaseMetaData* metaData_;
00052     DriverInfo* driverInfo_;
00053     
00054     //utilities
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     //private constructor, called from DriverManager
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 }; // namespace odbc
00208 
00209 
00210 #endif // __ODBCXX_CONNECTION_H

Go back to the freeodbc++ homepage