I am trying to access a SQL Server in two ways.
Method 1:
Using pyodbc after installing ODBC Driver in my local machine:
import pyodbc
conn = pyodbc.connect(driver='{ODBC Driver 18 for SQL Server}',
server=my_server,
database=my_database,
Trusted_Connection='yes',
uid=my_uid,
pwd=my_pwd,
domain=my_domain
)
Method 2:
Using jaydebeapi with JDBC mssql-jdbc-7.2.2.jre11.jar file
import jaydebeapi
conn = jaydebeapi.connect("com.microsoft.sqlserver.jdbc.SQLServerDriver",
f"""jdbc:sqlserver://my_server:1433;
databaseName=my_database""",
[my_uid, my_pwd],
"jars/mssql-jdbc-7.2.2.jre11.jar")
In method 1, I can download data fine. However, in method 2, I receive this error
com.microsoft.sqlserver.jdbc.SQLServerException: com.microsoft.sqlserver.jdbc.SQLServerException: Login failed for user 'my_uid'. ClientConnectionId:cc46fb71-72a8-4fed-ad85-d00cc2f01680
I am running both methods above from a MacBook (if that matters at all).
What causes the failed login for method 2? I obviously have access to the database since it works for method 1.