24 #ifndef Safir_Databases_Connection_h
25 #define Safir_Databases_Connection_h
27 #ifndef SAFIR_NO_DEPRECATED
30 #include "Safir/Databases/Odbc/Internal/InternalDefs.h"
33 #include <boost/noncopyable.hpp>
52 #pragma warning(disable: 4275)
53 #pragma warning(disable: 4251)
70 m_hConnection(SQL_NULL_HDBC),
75 CheckSQLWCHARSize(
sizeof(SQLWCHAR));
105 void Connect(
const std::wstring & wszConnectionString);
115 void Connect(
char * cszConnectionString);
137 void UseAutoTransactions();
147 void UseManualTransactions();
177 void SetConnectAttr(
long lAttribute,
long lValue);
187 void SetConnectAttr(
long lAttribute,
const std::wstring & wszValue);
197 void GetConnectAttr(
long lAttribute,
long & lValue)
const;
208 void GetConnectAttr(
long lAttribute,
wchar_t * wszValue,
unsigned long ulLength)
const;
220 bool GetDiagRec(
short sRecNumber,
221 std::wstring & SqlState,
222 boost::int32_t & NativeError,
223 std::wstring & MessageText,
224 bool & bDataRead)
const;
230 bool IsValid()
const;
236 bool IsConnected()
const;
242 SQLHDBC Handle()
const;
244 SQLHDBC m_hConnection;
247 typedef std::pair<std::wstring,std::wstring> StateMessagePair;
249 const StateMessagePair GetDiagRec()
const;
251 void AddStatement(
Statement * pStatement);
252 void RemoveStatement(
Statement * pStatement);
253 void EndTran(
short sCompletionType);
254 void ThrowReconnectException(
const std::wstring & fileName,
256 void ThrowReconnectException( SQLSMALLINT HandleType,
258 const std::wstring & fileName,
261 std::vector<Statement *> m_statements;
265 static void CheckSQLWCHARSize(
const size_t size);
275 SetConnectAttr(SQL_ATTR_AUTOCOMMIT, static_cast<long>(SQL_AUTOCOMMIT_ON));
281 SetConnectAttr(SQL_ATTR_AUTOCOMMIT, static_cast<long>(SQL_AUTOCOMMIT_OFF));
293 EndTran(SQL_ROLLBACK);
299 return m_hConnection != SQL_NULL_HDBC;
305 return m_bIsConnected;
311 return m_hConnection;
320 #endif //Safir_Databases_Connection_h
DotsC_Int64 Int64
64 bit integer type.
Definition: Defs.h:69
This namespace contains all the functionality and definitions of the SAFIR SDK.
Definition: Backdoor.h:30
Connection()
Constructor.
Definition: Connection.h:69
The Connection class models a connection made to the database engine.
Definition: Connection.h:64
bool IsValid() const
Checks if this connection is a valid allocated connection.
Definition: Connection.h:297
SQLHDBC Handle() const
Returns the ODBC Handle of the environment.
Definition: Connection.h:309
bool IsConnected() const
Checks if a connection has been established.
Definition: Connection.h:303
void UseAutoTransactions()
Set odbc to automatically commit each transaction after a successful query.
Definition: Connection.h:273
void Rollback()
Remove all changes made in this transaction.
Definition: Connection.h:291
void UseManualTransactions()
Set odbc to require manual commits to end transactions.
Definition: Connection.h:279
The Environment class models the necessary setup each application neeeds in order to access the datab...
Definition: Environment.h:54
void SetConnectAttr(long lAttribute, long lValue)
Sets a value for a ODBC connection attribute.
void Commit()
Commits the changes permanently made in this transaction.
Definition: Connection.h:285
The Statement class models a statement made to the database engine and one statement object should be...
Definition: Statement.h:64