9 #define SOCI_DB2_SOURCE 14 #pragma warning(disable:4355) 21 std::ostringstream ss(msg, std::ostringstream::app);
24 SQLCHAR message[SQL_MAX_MESSAGE_LENGTH + 1];
25 SQLCHAR sqlstate[SQL_SQLSTATE_SIZE + 1];
29 if ( SQLGetDiagRec(htype,
35 SQL_MAX_MESSAGE_LENGTH + 1,
36 &length) == SQL_SUCCESS ) {
44 size_t delimiter=keyVal.find_first_of(
"=");
45 std::string key=keyVal.substr(0,delimiter);
46 std::string value=keyVal.substr(delimiter+1,keyVal.length());
48 if (!key.compare(
"DSN")) {
51 if (!key.compare(
"Uid")) {
54 if (!key.compare(
"Pwd")) {
57 this->autocommit=
true;
58 if (!key.compare(
"autocommit")) {
59 if (!value.compare(
"off")) {
60 this->autocommit=
false;
67 std::string processingString(connectString);
68 size_t delimiter=processingString.find_first_of(
";");
69 while(delimiter!=std::string::npos) {
70 std::string keyVal=processingString.substr(0,delimiter);
72 processingString=processingString.erase(0,delimiter+1);
73 delimiter=processingString.find_first_of(
";");
75 if (!processingString.empty()) {
76 parseKeyVal(processingString);
85 SQLRETURN cliRC = SQL_SUCCESS;
88 cliRC = SQLAllocHandle(SQL_HANDLE_ENV,SQL_NULL_HANDLE,&
hEnv);
89 if (cliRC != SQL_SUCCESS) {
90 throw db2_soci_error(
"Error while allocating the enironment handle",cliRC);
93 cliRC = SQLAllocHandle(SQL_HANDLE_DBC,
hEnv, &
hDbc);
94 if (cliRC != SQL_SUCCESS) {
96 SQLFreeHandle(SQL_HANDLE_ENV,
hEnv);
102 cliRC = SQLSetConnectAttr(
hDbc,SQL_ATTR_AUTOCOMMIT, (SQLPOINTER)SQL_AUTOCOMMIT_ON, SQL_NTS);
104 cliRC = SQLSetConnectAttr(
hDbc,SQL_ATTR_AUTOCOMMIT, (SQLPOINTER)SQL_AUTOCOMMIT_OFF, SQL_NTS);
106 if (cliRC != SQL_SUCCESS) {
108 SQLFreeHandle(SQL_HANDLE_DBC,
hDbc);
109 SQLFreeHandle(SQL_HANDLE_ENV,
hEnv);
114 cliRC = SQLConnect(
hDbc, const_cast<SQLCHAR *>((
const SQLCHAR *)
dsn.c_str()), SQL_NTS,
115 const_cast<SQLCHAR *>((
const SQLCHAR *)
username.c_str()), SQL_NTS,
116 const_cast<SQLCHAR *>((
const SQLCHAR *)
password.c_str()), SQL_NTS);
117 if (cliRC != SQL_SUCCESS) {
119 SQLFreeHandle(SQL_HANDLE_DBC,
hDbc);
120 SQLFreeHandle(SQL_HANDLE_ENV,
hEnv);
135 SQLRETURN cliRC = SQLSetConnectAttr(
hDbc, SQL_ATTR_AUTOCOMMIT, (SQLPOINTER) SQL_AUTOCOMMIT_OFF, SQL_NTS);
136 if (cliRC != SQL_SUCCESS && cliRC != SQL_SUCCESS_WITH_INFO)
139 SQLFreeHandle(SQL_HANDLE_DBC,
hDbc);
140 SQLFreeHandle(SQL_HANDLE_ENV,
hEnv);
152 SQLRETURN cliRC = SQLEndTran(SQL_HANDLE_DBC,
hDbc,SQL_COMMIT);
155 SQLRETURN cliRC2 = SQLSetConnectAttr(
hDbc, SQL_ATTR_AUTOCOMMIT, (SQLPOINTER) SQL_AUTOCOMMIT_ON, SQL_NTS);
156 if ((cliRC == SQL_SUCCESS || cliRC == SQL_SUCCESS_WITH_INFO) &&
157 cliRC2 != SQL_SUCCESS && cliRC2 != SQL_SUCCESS_WITH_INFO)
160 SQLFreeHandle(SQL_HANDLE_DBC,
hDbc);
161 SQLFreeHandle(SQL_HANDLE_ENV,
hEnv);
165 if (cliRC != SQL_SUCCESS && cliRC != SQL_SUCCESS_WITH_INFO) {
175 SQLRETURN cliRC = SQLEndTran(SQL_HANDLE_DBC,
hDbc,SQL_ROLLBACK);
178 SQLRETURN cliRC2 = SQLSetConnectAttr(
hDbc, SQL_ATTR_AUTOCOMMIT, (SQLPOINTER) SQL_AUTOCOMMIT_ON, SQL_NTS);
179 if ((cliRC == SQL_SUCCESS || cliRC == SQL_SUCCESS_WITH_INFO) &&
180 cliRC2 != SQL_SUCCESS && cliRC2 != SQL_SUCCESS_WITH_INFO)
183 SQLFreeHandle(SQL_HANDLE_DBC,
hDbc);
184 SQLFreeHandle(SQL_HANDLE_ENV,
hEnv);
188 if (cliRC != SQL_SUCCESS && cliRC != SQL_SUCCESS_WITH_INFO) {
200 SQLFreeHandle(SQL_HANDLE_DBC,
hDbc);
201 SQLFreeHandle(SQL_HANDLE_ENV,
hEnv);
static const std::string sqlState(std::string const &msg, const SQLSMALLINT htype, const SQLHANDLE hndl)
db2_rowid_backend * make_rowid_backend()
std::string const & get_connect_string() const
void parseConnectString(std::string const &)
db2_statement_backend * make_statement_backend()
db2_blob_backend * make_blob_backend()
std::string connectString
db2_session_backend(connection_parameters const ¶meters)
void parseKeyVal(std::string const &)
std::vector< ISM::CombinatorialTrainerParameters > parameters