64 std::string passwordBytes = convertor.to_bytes(password); |
64 std::string passwordBytes = convertor.to_bytes(password); |
65 SQLRETURN result = SQLConnect(connection, |
65 SQLRETURN result = SQLConnect(connection, |
66 (SQLCHAR*) dataSourceNameBytes.c_str(), SQL_NTS, |
66 (SQLCHAR*) dataSourceNameBytes.c_str(), SQL_NTS, |
67 (SQLCHAR*) userNameBytes.c_str(), SQL_NTS, |
67 (SQLCHAR*) userNameBytes.c_str(), SQL_NTS, |
68 (SQLCHAR*) passwordBytes.c_str(), SQL_NTS); |
68 (SQLCHAR*) passwordBytes.c_str(), SQL_NTS); |
69 if (OdbcCommon::isNotSuccessful(result)) { |
69 if (OdbcCommon::isNotSuccessful(result)) throw SqlException(L"Unable to connect to DSN: " + dataSourceName, result, SQL_HANDLE_DBC, connection, true); |
70 OdbcCommon::freeHandle(SQL_HANDLE_DBC, connection); |
|
71 throw SqlException(L"Unable to connect to DSN: " + dataSourceName, result, SQL_HANDLE_ENV, environment); |
|
72 } |
|
73 return new Connection(connection); |
70 return new Connection(connection); |
74 } |
71 } |
75 |
72 |
76 Connection* DriverManager::getConnectionByURL(relpipe::reader::string_t connectionString) { |
73 Connection* DriverManager::getConnectionByURL(relpipe::reader::string_t connectionString) { |
77 SQLHDBC connection = OdbcCommon::allocateHandle(SQL_HANDLE_DBC, environment); |
74 SQLHDBC connection = OdbcCommon::allocateHandle(SQL_HANDLE_DBC, environment); |