Rohit Sharma
Rohit Sharma

Reputation: 15

isql not connecting to the database

I have installed unixodbc and mssql drivers on the centos machine , but i am not able to connecto to the remote database using isql database username password.

odbcinst -j

unixODBC 2.3.1
DRIVERS............: /etc/odbcinst.ini
SYSTEM DATA SOURCES: /etc/odbc.ini
FILE DATA SOURCES..: /etc/ODBCDataSources
USER DATA SOURCES..: /root/.odbc.ini
SQLULEN Size.......: 8
SQLLEN Size........: 8
SQLSETPOSIROW Size.: 8

cat /etc/odbcinst.ini (this file is blank)

I created an entry in /etc/odbc.ini

[empower]
Driver=ODBC Driver 13 for SQL Server
Description=ODBC Driver 13 for SQL Server
DSN=dsnname
Trace=No
Server=servername
Port=1433
Database=db_env
ApplicationIntent=ReadOnly


isql dsnname username password gives the below error :
[ISQL]ERROR: Could not SQLConnect

Need to know if i am doing anything wrong.

Upvotes: 0

Views: 4202

Answers (1)

Gord Thompson
Gord Thompson

Reputation: 123494

The file "/etc/odbcinst.ini" should not be empty. It should contain an entry similar to this one:

[ODBC Driver 13 for SQL Server]
Description=Microsoft ODBC Driver 13 for SQL Server
Driver=/opt/microsoft/msodbcsql/lib64/libmsodbcsql-13.1.so.9.0
UsageCount=1

(I have verified that the above entry is automatically added by the "RedHat Enterprise Server 7" instructions from here. Tested on a clean install of CentOS_7.)

Then your "/etc/odbc.ini" can define the DSN named "empower" as

[empower]
Driver=ODBC Driver 13 for SQL Server
Trace=No
Server=servername
Database=db_env
ApplicationIntent=ReadOnly

and isql should be able to connect with

isql empower MyID MyPWD

Upvotes: 2

Related Questions