29#include <sptk5/sptk.h>
33#include <sptk5/Strings.h>
42#define LPCVOID const void*
49#include <sptk5/db/QueryParameterList.h>
60class ODBCConnectionBase;
67class SP_DRIVER_EXPORT ODBCBase
70 friend class ODBCConnection;
73 static constexpr const char* cantSetConnectOption =
"Can't set connect option";
74 static constexpr const char* cantEndTranscation =
"Can't end transaction";
75 static constexpr const char* cantGetInformation =
"Can't get connect information";
80 ~ODBCBase() =
default;
85 [[noreturn]]
static void exception(
const String& text,
int line);
97 ODBCBase& operator=(
const ODBCBase& d);
102 ODBCBase(
const ODBCBase&);
110class SP_DRIVER_EXPORT ODBCEnvironment
113 friend class ODBCConnectionBase;
119 SQLHENV handle()
const
121 return m_hEnvironment.get();
128 ODBCEnvironment() =
default;
140 return m_hEnvironment !=
nullptr;
147 std::shared_ptr<uint8_t> m_hEnvironment;
155class SP_DRIVER_EXPORT ODBCConnectionBase
173 void connect(
const String& ConnectionString, String& FinalConnectionString,
bool EnableDriverPrompt =
false);
183 SQLHDBC handle()
const
185 return (SQLHDBC) m_hConnection.get();
193 std::scoped_lock lock(*
this);
200 void setConnectOption(UWORD fOption, UDWORD vParam);
205 String connectString()
207 std::scoped_lock lock(*
this);
208 return m_connectString;
214 String driverDescription()
216 std::scoped_lock lock(*
this);
217 return m_driverDescription;
223 void beginTransaction();
228 void transact(uint16_t fType);
235 transact(SQL_COMMIT);
243 transact(SQL_ROLLBACK);
249 static ODBCEnvironment& getEnvironment()
258 String errorInformation(
const char* action)
const;
266 return m_hConnection != SQL_NULL_HDBC;
273 void execQuery(
const char* query);
276 ODBCEnvironment& m_cEnvironment {getEnvironment()};
277 std::shared_ptr<uint8_t> m_hConnection;
278 bool m_connected {
false};
279 String m_connectString;
280 String m_driverDescription;
281 static ODBCEnvironment m_env;
287String removeDriverIdentification(
const char* error);