24 #ifndef Safir_Databases_Connection_h
25 #define Safir_Databases_Connection_h
28 #include "Safir/Databases/Odbc/Internal/InternalDefs.h"
31 #include <boost/noncopyable.hpp>
44 #pragma warning(disable: 4275)
45 #pragma warning(disable: 4251)
59 m_hConnection(SQL_NULL_HDBC),
64 CheckSQLWCHARSize(
sizeof(SQLWCHAR));
94 void Connect(
const std::wstring & wszConnectionString);
104 void Connect(
char * cszConnectionString);
126 void UseAutoTransactions();
136 void UseManualTransactions();
166 void SetConnectAttr(
long lAttribute,
long lValue);
176 void SetConnectAttr(
long lAttribute,
const std::wstring & wszValue);
186 void GetConnectAttr(
long lAttribute,
long & lValue)
const;
197 void GetConnectAttr(
long lAttribute,
wchar_t * wszValue,
unsigned long ulLength)
const;
209 bool GetDiagRec(
short sRecNumber,
210 std::wstring & SqlState,
211 boost::int32_t & NativeError,
212 std::wstring & MessageText,
213 bool & bDataRead)
const;
219 bool IsValid()
const;
225 bool IsConnected()
const;
231 SQLHDBC Handle()
const;
233 SQLHDBC m_hConnection;
236 typedef std::pair<std::wstring,std::wstring> StateMessagePair;
238 const StateMessagePair GetDiagRec()
const;
240 void AddStatement(
Statement * pStatement);
241 void RemoveStatement(
Statement * pStatement);
242 void EndTran(
short sCompletionType);
243 void ThrowReconnectException(
const std::wstring & fileName,
245 void ThrowReconnectException( SQLSMALLINT HandleType,
247 const std::wstring & fileName,
250 std::vector<Statement *> m_statements;
254 static void CheckSQLWCHARSize(
const size_t size);
264 SetConnectAttr(SQL_ATTR_AUTOCOMMIT, static_cast<long>(SQL_AUTOCOMMIT_ON));
270 SetConnectAttr(SQL_ATTR_AUTOCOMMIT, static_cast<long>(SQL_AUTOCOMMIT_OFF));
282 EndTran(SQL_ROLLBACK);
288 return m_hConnection != SQL_NULL_HDBC;
294 return m_bIsConnected;
300 return m_hConnection;
309 #endif //Safir_Databases_Connection_h
void Rollback()
Remove all changes made in this transaction.
Definition: Connection.h:280
void UseAutoTransactions()
Set odbc to automatically commit each transaction after a successful query.
Definition: Connection.h:262
DotsC_Int64 Int64
64 bit integer type.
Definition: Defs.h:70
void Commit()
Commits the changes permanently made in this transaction.
Definition: Connection.h:274
bool IsValid() const
Checks if this connection is a valid allocated connection.
Definition: Connection.h:286
Connection()
Constructor.
Definition: Connection.h:58
void SetConnectAttr(long lAttribute, long lValue)
Sets a value for a ODBC connection attribute.
The Statement class models a statement made to the database engine and one statement object should be...
Definition: Statement.h:59
bool IsConnected() const
Checks if a connection has been established.
Definition: Connection.h:292
The Environment class models the necessary setup each application neeeds in order to access the datab...
Definition: Environment.h:49
SQLHDBC Handle() const
Returns the ODBC Handle of the environment.
Definition: Connection.h:298
void UseManualTransactions()
Set odbc to require manual commits to end transactions.
Definition: Connection.h:268
The Connection class models a connection made to the database engine.
Definition: Connection.h:53