FreeTDS - tsql connects, isql fails - sql-server

I'm trying to connect to a database on my host machine (windows xp, sql server 05). My guest machine is Ubuntu 10.04. I can connect and execute commands with tsql, but isql fails. Below are my config files and error messages.
freetds.conf
text size = 64512
[SQLEXPRESS]
host = 192.168.163.1
port = 1433
tds version = 7.0
odbcinst.ini
[FreeTDS]
Description = TDS driver (Sybase/MS SQL)
Driver = /usr/lib/odbc/libtdsodbc.so
Setup = /usr/lib/odbc/libtdsS.so
CPTimeout =
CPReuse =
FileUsage = 1
odbc.ini
[SQLEXPRESS]
Driver = FreeTDS
Description = ODBC connection via FreeTDS
Trace = No
Servername = 192.168.163.1
Database = SCOPE_Peel
Port = 1433
UID = sa
PWD = test1234
ReadOnly = No
tsql:
tsql -S SQLEXPRESS -U sa
#success
isql:
isql SQLEXPRESS sa test1234 -v
[S1000][unixODBC][FreeTDS][SQL Server]Unable to connect to data source
[ISQL]ERROR: Could not SQLConnect

The issue was this line in odbc.ini
Servername = 192.168.163.1
It should have been SQLEXPRESS which I think points to the name of the server configured in freetds.conf

Related

QT unable to connect to mssql server from qt application in ubuntu

Unable to connect to mssql server from qt application in ubuntu 20.04
Sql server located in windows 7
The connection is definitely present, because it was possible to connect through DDbeaver.
Can anyone help me in this situation?
Code:
QSqlDatabase db = QSqlDatabase::addDatabase("QODBC3");
db.setConnectOptions();
QString serverName = "566***";
QString ipName = "tcp:192.168.144.101,1433";
QString dbName = "St***";
QString connectionString = QString("DRIVER={ODBC Driver 18 for SQL Server};Server=%1;Database=%2;").arg(ipName).arg(dbName);
db.setDatabaseName(connectionString);
db.setUserName("sa");
db.setPassword("top123TOP");
if (db.open())
{
qDebug() << "Correct connection";
}
else
{
QString error = db.lastError().text();
qDebug() << error;
}
otuput is:
"[Microsoft][ODBC Driver 18 for SQL Server]TCP Provider: Error code 0x2746 [Microsoft][ODBC Driver 18 for SQL Server]Client unable to establish connection QODBC3: Unable to connect"
odbcinst.ini
[ODBC Driver 18 for SQL Server]
Description=Microsoft ODBC Driver 18 for SQL Server
Driver=/opt/microsoft/msodbcsql18/lib64/libmsodbcsql-18.0.so.1.1
the following solution helped:
from:https://github.com/microsoft/msphpsql/issues/1112
This was helpful.
Ubuntu 20.04 PHP 7.4 using the 19.10 drivers for sqlsrv
We have a real old SQL server out there . The SQL Server show's version 10.50.2550.0, i think it's SQL Server 2008 R2. I had to use TLSv1 to connect to the server. I also had to do a "systemctl restart apache2" to get it to take affect. TLSv1.1 did not work with my MSSQL server version.
Error message: Connection failed: SQLSTATE[08001]: [Microsoft][ODBC Driver 17 for SQL Server]SSL Provider: [error:1425F102:SSL routines:ssl_choose_client_version:unsupported protocol]Database Connection Error
edit: /etc/ssl/openssl.cnf
1st line in the file added
openssl_conf = default_conf
End of file added
[default_conf]
ssl_conf = ssl_sect
[ssl_sect]
system_default = system_default_sect
[system_default_sect]
MinProtocol = TLSv1
CipherString = DEFAULT#SECLEVEL=1
Not 100% sure why i had to restart apache2 for it to take effect, but I had to.
systemctl restart apache2
reloaded the page and it works

Issues connecting to Docker MSSQL using pyodbc

I have pulled a docker image that runs an MS SQL from docker hub:
docker pull mcr.microsoft.com/mssql/server:2017-latest
docker run --name some-db -e ACCEPT_EULA=Y -e MSSQL_SA_PASSWORD=Aamerge1234 -e MSSQL_PID=Developer -d -p 1433:1433 mcr.microsoft.com/mssql/server:2017-latest
The container runs fine, I added a strong password as required.
This is the python code I am using to connect with the database using pyodbc:
import pyodbc
server = 'localhost:1433'
# database = ''
username = 'sa'
password = 'Aamerge1234'
conn = pyodbc.connect('DRIVER={SQL Server Native Client 11.0};SERVER='+server+';UID='+username+';PWD='+ password)
I have omitted the variable database because mssql creates several.
I tried using the following ODBC drivers:
ODBC Driver 17 for SQL Server
SQL Server
However, it always returns error:
OperationalError: ('08001', '[08001] [Microsoft][ODBC Driver 17 for SQL Server]Named Pipes Provider: Could not open a connection to SQL Server [53]. (53) (SQLDriverConnect); [08001] [Microsoft][ODBC Driver 17 for SQL Server]Login timeout expired (0); [08001] [Microsoft][ODBC Driver 17 for SQL Server]A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online. (53)')

Login failed for the user '' SQL Server when connecting using python from EMR server

I'm trying to connect to SQL Server Database from AWS EMR server.
$cat /etc/odbcinst.ini
[ODBC Driver 17 for SQL Server]
Description=Microsoft ODBC Driver 17 for SQL Server
Driver=/opt/microsoft/msodbcsql17/lib64/libmsodbcsql-17.8.so.1.1
UsageCount=1
and I modified the .odbc.ini file in my home directory like this.
$cat .odbc.ini
[ODBC Data Sources]
studylog = ODBC17Driver
[studylog]
Driver = /opt/microsoft/msodbcsql17/lib64/libmsodbcsql-17.8.so.1.1
Description = My Description
Server = hostname.amazonaws.com
output of odbcinst -j command
unixODBC 2.3.7
DRIVERS............: /etc/odbcinst.ini
SYSTEM DATA SOURCES: /etc/odbc.ini
FILE DATA SOURCES..: /etc/ODBCDataSources
USER DATA SOURCES..: /mnt/efs/home/username/.odbc.ini
SQLULEN Size.......: 8
SQLLEN Size........: 8
SQLSETPOSIROW Size.: 8
output of odbcinst -q -d command
[ODBC Driver 17 for SQL Server]
output of odbcinst -q -s command
[studylog]
Python script I'm using to connect to SQL Server
import pyodbc
host = "hostname.amazonaws.com"
user="DBUser"
password="Password"
db="dbname"
details = {
'server' : host,
'database' : db,
'username' : user,
'password' : password
}
# ODBC Driver 17 for SQL Server
connect_string = 'DRIVER={{ODBC Driver 17 for SQL Server}};SERVER={server};PORT={{1433}}; DATABASE={database};UID={username};PWD={password}'.format(**details)
connection = pyodbc.connect(connect_string)
print(connection)
output of my python script
pyodbc.InterfaceError: ('28000', "[28000] [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Login failed for user 'DBUser'. (18456) (SQLDriverConnect)")
What's going wrong in this? Thank you in advance.

ORA-12162: TNS:net service name is incorrectly specified

I'm trying to monitor my oracle db with zabbix by ODBC. My database version is 11.2 and I have the DB name, port, login and the password.
What I did until now is:
1- installed oracle instant client-basic, devel, sqlplus and odbc (all 11.2 version)
2- installed unixodbc and unix odbc-devel
and I configured some files:
/etc/oracle/tnsnames.ora
MY.DB.NAME =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP) (HOST = {i put my db host ip}) (PORT = 1521))
(CONNECT_DATA =
(SERVICE_NAME = MY.DB.NAME)
)
)
/etc/odbc.ini
[MY.DB.NAME]
Driver = OracleDriver
Server = {my db host ip}
User = dbuser
Password = db123
Port= 1521
Database = MY.DB.NAME
/etc/odbcinst.ini
[OracleDriver]
Description = Oracle ODBC driver for Oracle 11g
Driver=/usr/lib/oracle/11.2/client64/lib/libsqora.so.11.1
And I did some exports:
export ORACLE_HOME=/usr/lib/oracle/11.2/client64/lib;
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME;
export TNS_ADMIN=/etc/oracle;
I want to test my connection with isql command, but when I try:
isql MY.DB.NAME
I receive this error message. I've never do this before, I followed many tutorials but I'm lost

Error 20009 (severity 9):Unable to connect: Adaptive Server is unavailable or does not exist OS error 111, "Connection refused"

while trying to connect to remort mssql server by command
tsql -S SQLEXPRESS -U sa
passwod :sa
it throws error as
Error 20009 (severity 9):Unable to connect: Adaptive Server is unavailable or does not exist OS error 111, "Connection refused"
Steps i followed
/etc/freetds/freetdsconf.conf
[SQLEXPRESS]
host = 192.168.1.9
port = 1433
tds version = 8.0
client charset = UTF-8
/etc/odbcinst.ini
[FreeTDS]
Description = TDS driver (Sybase/MS SQL)
Driver =/usr/lib/i386-linux-gnu/odbc/libtdsodbc.so
Setup =/usr/lib/i386-linux-gnu/odbc/libtdsS.so
CPTimeout =
CPReuse =
FileUsage = 1
etc/odbc.ini
[SQLEXPRESS]
Driver = FreeTDS
Description = ODBC connection via FreeTDS
Trace = No
Servername = 192.168.1.9
Database = cakephp_results
Port = 1433
UID = sa
PWD = sa
ReadOnly = No
In your odbc.ini file change 'Servername = ' to 'Server = '. Then remove the UID, PWD and ReadOnly lines from that file temporarily. You may want to remove them altogether and pass in the credentials from your application.
Then, be sure that your MSSQL DB is allowing connections through port 1433, that SQL Server is not blocking the incoming server's IP address, and that you have the correct password.
Also, if that doesn't work, review these troubleshooting instructions:

Resources