src/DriverManager.cpp
branchv_0
changeset 40 0d67e271abb7
parent 38 a871779a4e3c
child 41 4b2d46989f44
equal deleted inserted replaced
39:b4af13653313 40:0d67e271abb7
    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);