How to fix the [unixODBC][Driver Manager]Data source name not found, and no default driver specified (ODBC::Error)
Asked Answered
T

4

11
/local/rvm/gems/ruby-1.9.2-p320/gems/activerecord-sqlserver-adapter-3.2.12/lib/active_record/connection_adapters/sqlserver_adapter.rb:455:in `initialize': IM002 (0) [unixODBC][Driver Manager]Data source name not found, and no default driver specified (ODBC::Error)

I have working copy of my app but suddenly overnight I left my system like that and this error started surfacing. Can anyone tell how to fix this one please?

Trenna answered 20/1, 2014 at 15:21 Comment(3)
I dont know what driver you are using, but I would guess either a update has changed things. Can you connect to the data source using isql? If you could post a copy of your /etc/odbc.ini and /etc/odbcinst.ini file it would let me see what its trying to connect to.Chlordane
I'm having this issue as well. Did you ever find a solution?Grudging
Yup! I changed the adapter to dblib instead of odbc and it worked.Trenna
N
21

There is no definitive answer to your question since you gave us nothing to work on.

However, the possible reasons for this are:

  1. the DSN you specified could not be found in your user or system odbc.ini files Run odbcinst -j to find where those files are Has someone changed/removed them?

  2. You set ODBCINI env var or ODBCSYSINI env var to point unixODBC at the location of your odbc.ini and odbcinst.ini files and now they are not set (or changed).

  3. Someone has removed or moved your ODBC driver

  4. You normally run your code as user A and now you are running it as user B and you are using user datasources or set ODBCINI env var.

... probably others but if you'd given us better information we wouldn't have to guess.

Neotropical answered 21/1, 2014 at 9:34 Comment(1)
Assuming I have the problem stated at point 4, what should I do to fix it?Jordan
M
14

You should start by setting up and configuring FreeTDS. Here is a sample configurations from my files, but I'm sure other variants will work also. One difference is that I'm using Django, but the result below still worked eventually, but it works much better with SQL authentication than with Windows Authentication.

From /etc/freetds/freetds.conf (use the IP of the server if DNS is not active for the server name).

# A typical Microsoft server
[MyServer]
        host = 10.0.0.10\path
        port = 1433
        tds version = 7.0

From /etc/odbcinst.ini

[FreeTDS]
Description = FreeTDS
Driver = /usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so

From /etc/odbc.ini

[ServerDSN]
Description = "Some Description"
Driver = FreeTDS
ServerName = MyServer
Server = ip_address
Port = 1433
Database = DBNAME

Then this command connects me to the database.

tsql -S MyServer -U username@servername -P password

Marquand answered 14/3, 2015 at 21:53 Comment(0)
G
1

Please verify the following:

  1. The driver configuration file is named odbcinst.ini and is provided in the same path / directory / folder as odbc.ini
  2. The ODBC Initialization Path is a path / directory and not an actual path to the file (i.e. /root/odbc.ini). Please provide a directory path to where both odbcinst.ini and odbc.ini files exist.
  3. The Driver name defined in odbcinst.ini is the same as the Driver attribute defined in the datasource of odbc.ini.
  4. Note: If odbcinst.ini has the driver defined as “[ODBC Driver 13 for SQL Server]” then verify the odbc.ini references “Driver=ODBC Driver 13 for SQL Server”

This solved my problem.

Source: https://support.microfocus.com/kb/doc.php?id=7017884

Grainger answered 12/12, 2020 at 23:37 Comment(0)
T
0

just a tip, in my case was not possible with Driver = FreeTDS and both variables "servername" and "server" in odbc.ini. I let only "server = ip" and "Driver = /usr/lib/i386-linux-gnu/odbc/libtdsodbc.so", worked fine.

Turrell answered 19/3, 2015 at 17:59 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.