equal
deleted
inserted
replaced
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)) { |
70 OdbcCommon::freeHandle(SQL_HANDLE_DBC, connection); |
70 OdbcCommon::freeHandle(SQL_HANDLE_DBC, connection); |
71 throw SqlException(L"Unable to connect to " + dataSourceName, result, SQL_HANDLE_ENV, environment); |
71 throw SqlException(L"Unable to connect to DSN: " + dataSourceName, result, SQL_HANDLE_ENV, environment); |
72 } |
72 } |
73 return new Connection(connection); |
73 return new Connection(connection); |
74 } |
74 } |
75 |
75 |
76 Connection* DriverManager::getConnectionByURL(relpipe::reader::string_t connectionString) { |
76 Connection* DriverManager::getConnectionByURL(relpipe::reader::string_t connectionString) { |
80 SQLSMALLINT completeConnectionStringLength = -1; |
80 SQLSMALLINT completeConnectionStringLength = -1; |
81 SQLRETURN result = SQLDriverConnect(connection, nullptr, |
81 SQLRETURN result = SQLDriverConnect(connection, nullptr, |
82 (SQLCHAR*) convertor.to_bytes(connectionString).c_str(), SQL_NTS, |
82 (SQLCHAR*) convertor.to_bytes(connectionString).c_str(), SQL_NTS, |
83 (SQLCHAR*) completeConnectionString, sizeof (completeConnectionString), &completeConnectionStringLength, |
83 (SQLCHAR*) completeConnectionString, sizeof (completeConnectionString), &completeConnectionStringLength, |
84 SQL_DRIVER_NOPROMPT); |
84 SQL_DRIVER_NOPROMPT); |
85 if (OdbcCommon::isNotSuccessful(result)) throw SqlException(L"Unable to connect to " + connectionString, result, SQL_HANDLE_ENV, environment); |
85 if (OdbcCommon::isNotSuccessful(result)) { |
|
86 OdbcCommon::freeHandle(SQL_HANDLE_DBC, connection); |
|
87 throw SqlException(L"Unable to connect to URL: " + connectionString, result, SQL_HANDLE_ENV, environment); |
|
88 } |
86 return new Connection(connection); |
89 return new Connection(connection); |
87 } |
90 } |
88 |
91 |
89 } |
92 } |
90 } |
93 } |