DBeaver: Use Windows authentication from linux to connect SQL Server - sql-server

I am using
Debian GNU/Linux 11
dbeaver Community Edition 22.3.0
to try to connect to Microsoft SQL Server 2017.
and I always get this error:
This driver is not configured for integrated authentication. ClientConnectionId:f159b733-7a07-4c03-983e-803e9fbd7a33
no mssql-jdbc_auth-9.2.0.x64 in java.library.path: [/usr/java/packages/lib, /usr/lib64, /lib64, /lib, /usr/lib]
no mssql-jdbc_auth-9.2.0.x64 in java.library.path: [/usr/java/packages/lib, /usr/lib64, /lib64, /lib, /usr/lib]
When I check driver configuration I see com.microsoft.sqlserver:mssql-jdbc_auth and mssql-jdbc_auth-9.2.0.x64.dll is missing.
$ ls ~/.local/share/DBeaverData/drivers/maven/maven-central/com.microsoft.sqlserver/
mssql-jdbc-9.2.0.jre8.jar
mssql-jdbc-9.2.0.jre8.pom
mssql-jdbc_auth-9.2.0.x64.pom
Should I have mssql-jdbc_auth-9.2.0.x64.dll? Can a dll work in Linux? Is there any workaround to simulate Windows authentication from Linux?

Related

Connecting to MSSQLServer 2019 on Windows11 from Apple macOS BigSur using VS for Mac 2022 v17.4

I have an apple desktop computer with Visual Studio for Mac 2022 version 17.4 and wanted to connect to a MS SQL Server database on a windows 11 computer. However, I am able to connect to the windows 11 computer from the Mac and use the shared folders. I have installed the Microsoft odbc drivers, also JDBC drivers. I installed DBeaver and tried but to no avail and lastly installed DBVisualizer which I was able to ping the sql server but still not able to connect. I am getting SQL Server browser not started. But I have verified it on the windows 11 computer that is starts automatically. I have also make sure it is allowed through the windows firewall. Below is the AppSettings.json file.
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"ConnectionStrings": {
"DefaultConnection": "ServerName=I-AM-I\\SQLEXPRESS;Initial Catalog=Anglophone;User Id=sa;Password=password;"
},
"AllowedHosts": "*"
}
I thought I was going to get the same result as on windows. I have tried installing Microsoft ODBC and followed the instructions using home-brew. I tried JDBC, DBeaver and finally DbVisualizer. When I use the iODBC administrator I get the following error: 08003 odbc driver connection not open.
When I use the DbVisualizer, I get the following error:
Product: DbVisualizer Free 14.0.1 (build: 3540)
OS: Mac OS X
OS Version: 11.7.1
OS Arch: x86_64
Java Version: 17.0.4.1
Java VM: OpenJDK 64-Bit Server VM
Java Vendor: Eclipse Adoptium
Java Home: /Applications/DbVisualizer.app/Contents/Resources/jre.bundle/Contents/Home
DbVis Home: /Applications/DbVisualizer.app/Contents/Resources/app
User Home: /Users/bainn
PrefsDir: /Users/bainn/.dbvis
SessionId: 131
BindDir: null
An error occurred while establishing the connection:
Long Message:
Cannot open database "AnglophoneLawReports" requested by the login. The login failed. ClientConnectionId:8f9f7741-c0cc-44ff-b1a9-0f8f079c000f
Details:
   Type: com.microsoft.sqlserver.jdbc.SQLServerException
   Error Code: 4060
   SQL State: S0001
I am just hoping to get a simple AppSettings.json connection string format that could connect to SQL server on windows 11. The ability to connect to sql server on windows 11 without installing any container on the mac.
Thank you

Connect to SQL Server using SQLAlchemy

I'm trying to connect to a SQL Server Express database using SQLALchemy and pyodbc, but I'm continuously getting the error:
(pyodbc.Error) ('IM002', '[IM002] [unixODBC][Driver Manager]Data
source name not found, and no default driver specified (0)
(SQLDriverConnect)')
And I really don't understand if my engine url is wrong or what else.
My scenario is the following:
I'm on a Mac
I have a docker container (based on a Debian image with unixodbc and unixodbc-dev) in which my python app tries to connect to...
a virtualbox virtual machine running windows 8 with SQL express 2014...
I configured a user for the SQL express, with SQL Server authentication:
user: ar_user
password: ar_psw
...then:
I configured TCP ports as 1433 and disabled dynamic ports (SQL Server Configuration Manager > Network Configurations > Protocols).
I turned off Windows Firewall.
I used an Host-only adapter for the VM running windows8
now...
The VM is accessible from the host (my mac), since a:
ping -c 3 vm-ip
succeed!
But although I tried every possible permutation of user, password, ip, server name and port:
'mssql+pyodbc://ar_user:ar_psw#vm-ip/master'
'mssql+pyodbc://ar_user:ar_psw#vm-ip:1433/master'
'mssql+pyodbc://IE10WIN8\\SQLEXPRESS'
'mssql+pyodbc://ar_user:ar_psw#IE10WIN8\\SQLEXPRESS'
'mssql+pyodbc://ar_user:ar_psw#IE10WIN8\\SQLEXPRESS:1433'
'mssql+pyodbc://ar_user:ar_psw#IE10WIN8\\SQLEXPRESS:1433/master'
...and many more!
I always get the "datasource not found error".
What should I do?
ps: the vm is pingable even in the docker container!
UPDATE (solved but not 100%):
I solved in this way:
I configured FreeTDS driver using /etc/odbcinst.ini in this way:
[FreeTDS]
Description = TDS driver (Sybase/MS SQL)
Driver = /usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so
Setup = /usr/lib/x86_64-linux-gnu/odbc/libtdsS.so
client charset = UTF-8
and in /etc/freetds/freetds.conf:
[global]
tds version = 7.3
client charset = UTF-8
Then I created the engine using the following string:
'mssql+pyodbc://my_user:my_psw#machine_ip:1433/my_db?driver=FreeTDS'
It seems to work properly, but I get this warning:
SAWarning: Unrecognized server version info '95.12.255'. Version
specific behaviors may not function properly. If using ODBC with
FreeTDS, ensure TDS_VERSION 7.0 through 7.3, not 4.2, is configured in
the FreeTDS configuration.
I also defined the TDS version using environment variables but it doesn't fix the issue... any idea?
I wrote a tutorial here of how to do this. Essentially, you need to:
brew install unixodbc
brew install freetds --with-unixodbc
Add the freetds driver to odbcinst.ini
Add a DSN (Domain Source Name) to odbc.ini named "MY_DSN"
pip install pyodbc
e = create_engine("mssql+pyodbc://username:password#MY_DSN")
The walkthrough here does a much more thorough job of explaining this, including issues with SQL Server/FreeTDS Protocol Version Compatibility.

PDO_ODBC and unixODBC cannot connect MSSQL with non-default port

I have to connect two MSSQL servers on php/linux environment. So I decide to use unixODBC and PDO_ODBC.
mssql on server1: 10.10.10.5:1433
mssql on server2: 10.10.10.8:14233 (non-default port number)
I think there is a port problem of PDO_ODBC or unixODBC. I tried some code below.
This code works fine. connected successfully.
$db = new PDO('odbc:Driver=SQL Server Native Client 11.0; Server=10.10.10.5; Port=1433; Database=dbname; UID=uid; PWD=pwd');
This code didn't work. connect failed.
$db = new PDO('odbc:Driver=SQL Server Native Client 11.0; Server=10.10.10.8; Port=14233; Database=dbname; UID=uid; PWD=pwd');
Strangely, This code also works fine with wrong value. :(
$db = new PDO('odbc:Driver=SQL Server Native Client 11.0; Server=10.10.10.5; Port=14233; Database=dbname; UID=uid; PWD=pwd');
I concluded that someone ignore port setting on dsn of PDO.
I also tried to other setting using /etc/odbc.ini
[odbc-erp]
Driver=SQL Server Native Client 11.0
Description=MSSQL
Trace=Yes
Server=10.10.10.8
Port=14233
Database=dbname
And, this code didn't make connection.
$dbh = new PDO('odbc:odbc-erp', $uid, $pwd);
Error message:
DB Error: SQLSTATE[HYT00] SQLConnect: 0 [unixODBC][Microsoft][SQL Server Native Client 11.0]Login timeout expired in /home/user/public_html/test/testodbc.php on line 40
AND, this code works fine.
[odbc-mes]
Driver=SQL Server Native Client 11.0
Description=MSSQL
Trace=Yes
Server=10.10.10.5
Port=14233 // Wrong value (10.10.10.5 server port is 1433.)
Database=dbname
And, this code didn't make connection.
$dbh = new PDO('odbc:odbc-mes', $uid, $pwd);
The ports is all opened. tcpdump show the connection use always use ms-sql-s (1433).
sqlcmd is works fine.
# sqlcmd -U uid -P pwd -S 10.10.10.8,14233 -d OES
1> select ##version
2> go
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Microsoft SQL Server 2008 R2 (SP2) - 10.50.4033.0 (X64)
Jul 9 2014 16:04:25
Copyright (c) Microsoft Corporation
Enterprise Edition (64-bit) on Windows NT 6.1 <X64> (Build 7601: Service Pack 1)
(1 rows affected)
1>
I wonder what I'm missing. Or is there the other way to connect with mssql?
CentOS 6.6
PHP 5.5.19
sqlncli-11.0.1790.0
-
# rpm -qa
php-5.5.19-2.el6.remi.x86_64
php-mssql-5.5.19-2.el6.remi.x86_64
php-odbc-5.5.19-2.el6.remi.x86_64
php-pdo-5.5.19-2.el6.remi.x86_64
# sqlcmd
Microsoft (R) SQL Server Command Line Tool
Version 11.0.1790.0 Linux
Copyright (c) Microsoft Corporation. All rights reserved.
# cat /etc/sysconfig/selinux
SELINUX=disabled
SELINUXTYPE=targeted
The driver doesn't support a Port keyword. Per the documentation, you need to append the port after the server name in the DSN:
Server=10.10.10.5,14233
The documentation also lists the keywords that are supported.

Drupal-6.25 and SQL Server 2005 slow on Linux, but fast on Windows

I've been experimenting with Drupal-6.25 installation on SQL Server 2005. I got the MSSQL driver patch from http://drupal.org/files/d6mssql.zip
The problem is, when I use Linux as OS' web server, the performance is very slow. Each page needs between 10 to 20 seconds to load.
This problem is no more when I use Windows as OS' web server. Loading page needs just miliseconds.
The Linux configurations are as follows (I tested with many Linux distros):
VMWare Workstation 8.0
Ubuntu 10.04 / Ubuntu 12.04 / Fedora 16 (IP: 192.168.14.12x)
Latest Apache2, Latest PHP 5.3.10
php5-sybase on Ubuntu, freetds on Fedora
SQL Server 2005 on my Windows-7 machine (IP: 125.0.0.7).
The Windows configuration is as follows:
Windows 7 x64 (IP: 125.0.0.7)
XAMPP 1.7.3 with PHP 5.3.8 and Freetds extension from http://docs.moodle.org/20/en/Installing_MSSQL_for_PHP
Both system, use this freetds config:
[global]
host = 125.0.0.7
port = 1433
client charset = UTF-8
tds version = 8.0
text size = 20971520
Anyone has suggestions or maybe some debugging help?
Thanks!

Symfony2 and Microsoft SQL Server on Mac and MAMP

I´m going to develop a Symfony2 application in my Mac OSX with MAMP, but the database (a Microsoft SQL Server one) is in another computer.
I setup everything (I followed this instruction http://jesusomar.com/2011/07/22/mamp-php-and-mssql )and if I check phpinfo() I see that mssql is active, but I´m getting this error:
[PDOException]
could not find driver
any help or clue? Thanks in advance
The first step is to check if FreeTDS is installed. You can run tsql -C to get information about MSSQL libraries in your computer. You should get something like this:
Version: freetds v0.91
freetds.conf directory: /usr/local/Cellar/freetds/0.91/etc
MS db-lib source compatibility: no
Sybase binary compatibility: no
Thread safety: yes
iconv library: yes
TDS version: 7.1
iODBC: no
unixodbc: no
SSPI "trusted" logins: no
Kerberos: no
If FreeTDS is not installed, you can do it with Homebrew (for example): brew install freetds.
Now you can use MssqlBundle to connect with your database.

Resources