Articles Easy install SQL Server driver in Ubuntu by Luis Navarro

emailx45

Местный
Регистрация
5 Май 2008
Сообщения
3,571
Реакции
2,438
Credits
573
Easy install SQL Server driver in Ubuntu by Luis Navarro
Luis Navarro - 2 abril, 2017
[SHOWTOGROUPS=4,20]
It’s quite exciting to develop Delphi and C++ Builder applications for Linux using the brand new RAD Studio 10.2 Tokyo release. So I can imagine that many developers are now starting new projects targeting Linux, or adapting their existing ones to the new platform.

Many of these project will surely use database connections, and the most widely used Enterprise database engine is Microsoft SQL Server (acording to different surveys).
I set up a new Ubuntu Server 16.04 (following the great guides by PAWEŁ GŁOWACKI Для просмотра ссылки Войди или Зарегистрируйсяand CRAIG CHAPMAN Для просмотра ссылки Войди или Зарегистрируйся). But when I started to develop a sample Linux application that connects to an SQL Server database, I found some problems to get the application connecting without issues to the server.

First of all, the documentation that explains the steps to install the necessary drivers is split in two docwiki pages: Для просмотра ссылки Войди или Зарегистрируйся and Для просмотра ссылки Войди или Зарегистрируйся (I have to admit that with the excitement of the new development, I missed the first link ). There are a few steps in each of the pages, so it takes some time to get all things set up.

Then I launched the application and I got this error:
EFDException: [FireDAC][Phys][ODBC]-314. Cannot load vendor library [libodbc.so]. Hint: check it is in the PATH or application EXE directories, and has x64 bitness.
04_Error


I followed all the steps again with no success. So I prepared a new Ubuntu Server installation, installed the drivers again with the same result.

With the invaluable help of my very good friend Agustín Terol, we found that some libraries were still missing in the system: the FreeTDS ones. After installing those libraries and a few tweaks here and there, we got the application running successfully.

Then we prepared a simple script file, that everyone could execute and get easily their systems ready to connect their Delphi and C++ Builder applications to a MS SQL Server database. Of course, this script is for Ubuntu systems. You can download the script Для просмотра ссылки Войди или Зарегистрируйся. Disclaimer: use at your own responsibility, it’s not guarantee that this script works in every system, and it’s not our responsibility any undesired effects that may cause in your system.

In resume, to get an Ubuntu Server 16.04 ready to run SQL Server-based applications, follow these steps:
  1. Get your Ubuntu Server installed following any of these guides: Для просмотра ссылки Войди или Зарегистрируйся or Для просмотра ссылки Войди или Зарегистрируйся
  2. Get the script into the Ubuntu server
    1. Download it using wget in the command line: wget community.embarcadero.com/uploads/11274/04_sqlserver_driver/sqlserverdriver.tar
    2. Copy it to the server using the WinSCP tool
  3. Extract the script file from the sqlserverdriver.tar, usign the following command: tar xvf sqlserverdriver.tar
  4. 04_wget_tar
  5. Execute the script: ./sqlserverdriver.sh
  6. After a few minutes you will get your system properly configured.
    04_success

Here there are a couple of screenshots that show the same application running on Linux and Windows:

04_Linux

04_Windows


With this environment I can easily develop and deploy REST-based microservices in Linux that connect to MS SQL Server, or applications that execute scheduled jobs (to send e-mails, perform billing, …), or use RAD Server connecting to SQL Server, etc…

There is a huge ammount of amazing oportunities by developing for Linux with Для просмотра ссылки Войди или Зарегистрируйся, don’t miss them!!

[/SHOWTOGROUPS]