question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

username/password not working in connection string

See original GitHub issue

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?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:19 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
julianhydecommented, Jul 23, 2019

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.

0reactions
julianhydecommented, Oct 14, 2019

Revised fix in ee2d81d5aab2607d65fd847e3086d14458694967. (We removed -no-np and added connectInteractionMode property.)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Setting connection string with username and password in ASP ...
I am working on my first ASP.NET Core MVC application.What is the right way to specify the connection string in a ASP.NET Core...
Read more >
Username and password in Connection string - CodeProject
Hi,. I am trying to connect to a database server that my domain login name does not have access too. But in ...
Read more >
SQL connection string ignoring specified username ... - MSDN
I'm having a problem with my SQL Connection strings not using the ... a specific username/password beacuse SQLServer2 is not on the domain....
Read more >
use variables for Username, Password, IP address, Port etc ...
Hello, I was successfully able to made a connection to my Oracle database via the “DatabaseConnect” activity in Studio.
Read more >
ODBC. Query connector- Provide username password i...
Query connector- Provide username password in connection string ... syntax anywhere on the internet not even in the official documentation.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found