I've added Ubuntu 20.04
under AD Domain controller and have installed MsSQL
Server on Ubuntu machine.
My sqlcmd localhost
works perfectly with windows authentication
$ sqlcmd -S localhost
1> select @@version
2> GO
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Microsoft SQL Server 2019 (RTM-CU10) (KB5001090) - 15.0.4123.1 (X64)
Mar 22 2021 18:10:24
Copyright (C) 2019 Microsoft Corporation
Developer Edition (64-bit) on Linux (Ubuntu 20.04.2 LTS) <X64>
(1 rows affected)
1>
Now, I'm trying to connect it with Simple Java code as
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.DriverManager;
import java.sql.SQLException;
/**
* This program demonstrates how to establish database connection to Microsoft
* SQL Server.
*
*/
public class JdbcSQLServerConnection {
public static void main(String[] args) {
Connection conn = null;
try {
String dbURL = "jdbc:sqlserver://170.18.xx.xx:1433;integratedSecurity=true";
String user = "sa";
String pass = "*****************";
conn = DriverManager.getConnection(dbURL, user, pass);
if (conn != null) {
DatabaseMetaData dm = (DatabaseMetaData) conn.getMetaData();
System.out.println("Driver name: " + dm.getDriverName());
System.out.println("Driver version: " + dm.getDriverVersion());
System.out.println("Product name: " + dm.getDatabaseProductName());
System.out.println("Product version: " + dm.getDatabaseProductVersion());
}
} catch (SQLException ex) {
ex.printStackTrace();
} finally {
try {
if (conn != null && !conn.isClosed()) {
conn.close();
}
} catch (SQLException ex) {
ex.printStackTrace();
}
}
}
}
I ran this source code as
java -cp mssql-jdbc-8.4.1.jre8.jar:sqljdbc4.jar:. -Djava.library.path=mssql-jdbc_auth-8.4.1.x64.dll JdbcSQLServerConnection
It throws exception as Caused by: java.lang.UnsatisfiedLinkError: no mssql-jdbc_auth-8.4.1.x64 in java.library.path
I found below few unanswered threads but not sure if they have added their machines under any DC
java.library.path
, not the classpath. Hint: Thejava.library.path
is by default the same as thePATH
environment variable. – Salaam.DLL
will work onUbuntu
machines? – Fleeta.so
file, not the.dll
file. – SalaamMsSQL Server
Windows authentication? I'm not getting it. – Fleetajdbc:sqlserver://170.18.xx.xx\\MSSQLSERVER;
, or a port,jdbc:sqlserver://170.18.xx.xx:1433;
, not both. Since you already know the port number use that. – Intoxicativeauth
library for Linux. – SalaamPort No
in JDBC URL, it is working fine. But, what you advise forauthenticating
it onUbuntu
machine – Fleeta