/*
This file is part of libodbc++.
Copyright (C) 1999-2000 Manush Dodunekov <manush@stendahls.net>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef __ODBCXX_CONNECTION_H
#define __ODBCXX_CONNECTION_H
#include <odbc++/setup.h>
#include <odbc++/types.h>
#include <odbc++/errorhandler.h>
namespace odbc {
class DriverInfo;
class DatabaseMetaData;
class Statement;
class PreparedStatement;
class CallableStatement;
class ODBCXX_EXPORT Connection : public ErrorHandler {
friend class DriverManager;
friend class Statement;
friend class DatabaseMetaData;
friend class DriverInfo;
private:
struct PD;
SQLHDBC hdbc_;
// private data
PD* pd_;
DatabaseMetaData* metaData_;
DriverInfo* driverInfo_;
#ifdef ODBCXX_ENABLE_THREADS
Mutex access_;
#endif
//utilities
SQLUINTEGER _getNumericOption(SQLINTEGER optnum);
ODBCXX_STRING _getStringOption(SQLINTEGER optnum);
void _setNumericOption(SQLINTEGER optnum, SQLUINTEGER value);
void _setStringOption(SQLINTEGER optnum, const ODBCXX_STRING& value);
SQLHSTMT _allocStmt();
//private constructor, called from DriverManager
Connection(SQLHDBC h);
void _connect(const ODBCXX_STRING& dsn,
const ODBCXX_STRING& user,
const ODBCXX_STRING& password);
void _connect(const ODBCXX_STRING& connectString);
void _registerStatement(Statement* stmt);
void _unregisterStatement(Statement* stmt);
const DriverInfo* _getDriverInfo() const {
return driverInfo_;
}
public:
enum TransactionIsolation {
TRANSACTION_NONE,
TRANSACTION_READ_UNCOMMITTED,
TRANSACTION_READ_COMMITTED,
TRANSACTION_REPEATABLE_READ,
TRANSACTION_SERIALIZABLE
};
virtual ~Connection();
bool getAutoCommit();
void setAutoCommit(bool autoCommit);
void commit();
void rollback();
ODBCXX_STRING getCatalog();
void setCatalog(const ODBCXX_STRING& catalog);
TransactionIsolation getTransactionIsolation();
void setTransactionIsolation(TransactionIsolation isolation);
bool isReadOnly();
void setReadOnly(bool readOnly);
bool getTrace();
void setTrace(bool on);
ODBCXX_STRING getTraceFile();
void setTraceFile(const ODBCXX_STRING& s);
DatabaseMetaData* getMetaData();
Statement* createStatement();
Statement* createStatement(int resultSetType,
int resultSetConcurrency);
PreparedStatement* prepareStatement(const ODBCXX_STRING& sql);
PreparedStatement* prepareStatement(const ODBCXX_STRING& sql,
int resultSetType,
int resultSetConcurrency);
CallableStatement* prepareCall(const ODBCXX_STRING& sql);
CallableStatement* prepareCall(const ODBCXX_STRING& sql,
int resultSetType,
int resultSetConcurrency);
ODBCXX_STRING nativeSQL(const ODBCXX_STRING& sql);
};
}; // namespace odbc
#endif // __ODBCXX_CONNECTION_H