Connect To SQL Server With Windows Authentication From A Linux Machine Through JDBC
Well, eventually I answer my own question:
This is not possible to use Windows authentication from a linux machine using the Microsoft JDBC driver.
This is possible using the jTDS JDBC driver using the following connection string:
jdbc:jtds:sqlserver://host:port;databaseName=dbname;domain=domainName;useNTLMv2=true;
Thank you all for all the comments
JDBC: Connect to MS SQL DB via SSL from Linux machine
Either connect using SQL Server Auth, passing a user name and password in the connection url, as per:
https://docs.microsoft.com/en-us/sql/connect/jdbc/step-3-proof-of-concept-connecting-to-sql-using-java?view=sql-server-2017
Or configure Kerberos:
https://docs.microsoft.com/en-us/sql/connect/jdbc/using-kerberos-integrated-authentication-to-connect-to-sql-server?view=sql-server-2017
Using windows authentication for SQL Server JDBC with pyspark
As shown here you can set the integratedSecurity=true
to connect to SQL Server via jdbc and Windows Authentication.
Then Spark configuration it should look as next:
mssql_df = spark.read.format("jdbc") \
.option("url", "jdbc:sqlserver://localhost:1433;databaseName=DATABASE-NAME;integratedSecurity=true") \
.option("dbtable", "database-table-name") \
.option("driver", "com.microsoft.sqlserver.jdbc.SQLServerDriver") \
.load()
UPDATE:
As discussed in the comments user should place sqljdbc_auth.dll
in the same folder where mssql-jdbc-7.4.1.jre12.jar
lives or just set spark.driver.extraClassPath
for both jars seperated by : as shown below:
.config("spark.driver.extraClassPath","/path.to/mssql-jdbc-6.4.0.jre8.jar:/path/to/sqljdbc_auth.dll")
sqljdbc_auth.dll is part of the Microsoft JDBC Driver 6.0 for SQL Server and you can download it from here. Alternatively you can just install JDBC driver on your system and specify the path where the dll is stored.
Can I connect to SQL Server using Windows Authentication from Java EE webapp?
I do not think one can push the user credentials from the browser to the database (and does it makes sense ? I think not)
But if you want to use the credentials of the user running Tomcat to connect to SQL Server then you can use Microsoft's JDBC Driver.
Just build your JDBC URL like this:
jdbc:sqlserver://localhost;integratedSecurity=true;
And copy the appropriate DLL to Tomcat's bin directory (sqljdbc_auth.dll provided with the driver)
MSDN > Connecting to SQL Server with the JDBC Driver > Building the Connection URL
Related Topics
How to Compare Two Double Values in Java
Why the Operating System Says It Can't Allocate Memory to Jvm When It Has Enough Memory
From What Linux Kernel/Libc Version Is Java Runtime.Exec() Safe with Regards to Memory
Unsatisfiedlinkerror When Using Jni
Why Do I Get "Exception; Must Be Caught or Declared to Be Thrown" When I Try to Compile My Java Code
Failed to Load the Jni Shared Library (Jdk)
How to Convert an Arraylist Containing Integers to Primitive Int Array
How to Parse JSON Array with Gson
How to Set Addsnapshotlistener and Remove in Populateviewholder in Recyclerview Item
Foreign Key Constraints in Android Using SQLite? on Delete Cascade
Firebase No Properties to Serialize Found on Class
What's the Location of the Javafx Runtime Jar File, Jfxrt.Jar, on Linux
What Would Cause a Java Process to Greatly Exceed the Xmx or Xss Limit
File.Encoding Has No Effect, Lc_All Environment Variable Does It
How Does a Jvm Process Allocate Its Memory
Commons Vfs and Java.Net.Url - Adding Support for "Sftp://" Protocol
In Linux, How to Execute Java Jar File with External Jar Files