| 917 | } |
| 918 | |
| 919 | SQLRETURN SQLConnect(SQLHDBC conn, SQLWCHAR* dsn_name, SQLSMALLINT dsn_name_len, |
| 920 | SQLWCHAR* user_name, SQLSMALLINT user_name_len, SQLWCHAR* password, |
| 921 | SQLSMALLINT password_len) { |
| 922 | ARROW_LOG(DEBUG) << "SQLConnectW called with conn: " << conn |
| 923 | << ", dsn_name: " << static_cast<const void*>(dsn_name) |
| 924 | << ", dsn_name_len: " << dsn_name_len |
| 925 | << ", user_name: " << static_cast<const void*>(user_name) |
| 926 | << ", user_name_len: " << user_name_len |
| 927 | << ", password: " << static_cast<const void*>(password) |
| 928 | << ", password_len: " << password_len; |
| 929 | |
| 930 | using ODBC::ODBCConnection; |
| 931 | |
| 932 | using ODBC::SqlWcharToString; |
| 933 | |
| 934 | return ODBCConnection::ExecuteWithDiagnostics(conn, SQL_ERROR, [=]() { |
| 935 | ODBCConnection* connection = reinterpret_cast<ODBCConnection*>(conn); |
| 936 | std::string dsn = SqlWcharToString(dsn_name, dsn_name_len); |
| 937 | |
| 938 | config::Configuration config; |
| 939 | config.LoadDsn(dsn); |
| 940 | |
| 941 | if (user_name) { |
| 942 | std::string uid = SqlWcharToString(user_name, user_name_len); |
| 943 | config.Emplace(FlightSqlConnection::UID, std::move(uid)); |
| 944 | } |
| 945 | |
| 946 | if (password) { |
| 947 | std::string pwd = SqlWcharToString(password, password_len); |
| 948 | config.Emplace(FlightSqlConnection::PWD, std::move(pwd)); |
| 949 | } |
| 950 | |
| 951 | std::vector<std::string_view> missing_properties; |
| 952 | |
| 953 | connection->Connect(dsn, config.GetProperties(), missing_properties); |
| 954 | |
| 955 | return SQL_SUCCESS; |
| 956 | }); |
| 957 | } |
| 958 | |
| 959 | SQLRETURN SQLDisconnect(SQLHDBC conn) { |
| 960 | ARROW_LOG(DEBUG) << "SQLDisconnect called with conn: " << conn; |