sqlline: username/password not working in connection string

I have been testing the mssql-jdbc 7.3.1 driver using NTLM authentication to SQL Server. Using sqlline, it’s working for me if I specify username/password as args:

sqlline \
-u "jdbc:sqlserver://MY_SERVER;integratedSecurity=true;authenticationScheme=NTLM;domain=MY_DOMAIN" \
-n MY_USERNAME \
-p MY_PASSWORD \
-d com.microsoft.sqlserver.jdbc.SQLServerDriver \
-e 'select name from sys.databases'

But I get an error when I put the username/password in the connection string

sqlline \
-u "jdbc:sqlserver://MY_SERVER;integratedSecurity=true;authenticationScheme=NTLM;domain=MY_DOMAIN;user=MY_USERNAME;password=MY_PASSWORD" \
-d com.microsoft.sqlserver.jdbc.SQLServerDriver \
-e 'select name from sys.databases'

Jul 16, 2019 8:41:47 PM com.microsoft.sqlserver.jdbc.SQLServerConnection connectInternal
SEVERE: ConnectionID:1 "User" (or "UserName") and "Password" connection properties must be specified for NTLM authentication.
Error: "User" (or "UserName") and "Password" connection properties must be specified for NTLM authentication. (state=,code=0)
com.microsoft.sqlserver.jdbc.SQLServerException: "User" (or "UserName") and "Password" connection properties must be specified for NTLM authentication.
        at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectInternal(SQLServerConnection.java:1620)
...
No current connection
sqlline version 1.8.0

This works using the jTDS driver

sqlline \
-u "jdbc:jtds:sqlserver://MY_SERVER;domain=MY_DOMAIN;user=MY_USERNAME;password=MY_PASSWORD" \
-d net.sourceforge.jtds.jdbc.Driver \
-e 'select name from sys.databases'

I posted to https://github.com/microsoft/mssql-jdbc/issues/696#issuecomment-512056901 and the developers confirmed that the driver is working for other clients when specifying the username/password in the connection string. Additional details

[egagne:/opt/sqllinedir] [v] 7s $ ./sqlline
sqlline version 1.8.0
sqlline> !scan
scan complete in 167ms
2 driver classes found
Compliant Version Driver Class
yes       7.3     com.microsoft.sqlserver.jdbc.SQLServerDriver
no        1.3     net.sourceforge.jtds.jdbc.Driver

Do you think this is an issue on the sqlline side?

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 19 (7 by maintainers)

Most upvoted comments

If the username and password parameters are not present on the command line then sqlline shouldn’t add them to the Properties object (with values null or empty string). If that is happening I see why mssql is getting confused and we should fix it.