SlideShare a Scribd company logo
3
Most read
7
Most read
8
Most read
Qt is Cute!
Qt is Cute!
Usage Note of
Qt ODBC
Database Access
On Linux
William.L
wiliwe@gmail.com
2015-10-05
Qt is Cute!
Qt is Cute!
Index
What is ODBC? ............................................................................................................................................................ 3
Environment................................................................................................................................................................ 4
Install unixODBC Driver/Library/Tool......................................................................................................................... 5
Install MS SQL Server ODBC Driver/Tool.................................................................................................................... 9
Install Qt ODBC SQL Driver Plugin ............................................................................................................................ 13
Creating an ODBC Data Source Name (DSN) for Linux............................................................................................. 16
unixODBC GUI Configuring Tool........................................................................................................................ 19
Qt SQL Programming................................................................................................................................................. 20
Reference................................................................................................................................................................... 23
Qt is Cute!
Qt is Cute!
What is ODBC?
ODBC is the acronym for Open DataBase Connectivity, a Microsoft Universal Data Access standard that started
life as the Windows implementation of the X/Open SQL Call Level Interface specification.
Since its inception in 1992 it has rapidly become the industry standard interface for developing database
independent applications.
Example codes using Qt Core SQL library and relavant reference for this documentation could be downloaded
from the GitHub:
https://github.com/wiliwe/qt-sql-odbc-prog-example
Qt is Cute!
Qt is Cute!
Environment
* Linux CentOS 6.5 64-bit (upgraded to 6.7)
* Qt v5.4.1
* Qt Creator v3.3.1
* unixODBC library v2.3.4 (built out from source file)
* Microsoft SQL Server ODBC driver for RedHat 6
The relationship/architecture of the softwares used for the access of MS SQL Server through ODBC driver is shown
as below block diagram:
Cause to that unixODBC library is depended by MS SQL Server ODBC driver for Linux and Qt SQL driver plugin, so
the first software to be installed is unixODBC library.
Linux CentOS 6.5
MS Windows
MS
SQL
Server
Qt
Application
MS SQL Server
ODBC Driver
For RedHat
Qt ODBC
Driver Plug-in
unixODBC
Driver
Manager
odbc.ini odbcinst.ini
Qt
Core Library
IP
network
Qt is Cute!
Qt is Cute!
Install unixODBC Driver/Library/Tool
On Unix/Linux system, it is recommended that you use unixODBC library (http://www.unixodbc.org). Qt SQL
ODBC driver plugin depends on it, so you need the unixODBC header files and shared libraries.
1) First of all, remove all installed unixODBC libraries and tools in the system.
# su (change to root)
$ yum erase unixodbc*
2) Download unixODBC source archive from one of below sites:
* http://www.unixodbc.org/download.html
* ftp://ftp.unixodbc.org/pub/unixODBC/
Here using v2.3.4, the source archive file is unixODBC-2.3.4.tar.gz.
Note:
There are two open source ODBC driver managers for UNIX/Linux systems:
* unixODBC
User Manual
http://www.unixodbc.org/doc/
* iODBC
http://www.iodbc.org/dataspace/iodbc/wiki/iODBC/
Qt is Cute!
Qt is Cute!
3) Unpack the source archive and it will create a folder named unixODBC-2.3.4.
$ tar zxvf unixODBC-2.3.4.tar.gz
4) Enter the unixODBC-2.3.4 folder and run commands:
$ ./configure --prefix=/usr --libdir=/usr/lib64 --sysconfdir=/etc --disable-gui --disable-drivers
--enable-stats=no --enable-iconv --with-iconv-char-enc=UTF8 --with-iconv-ucode-enc=UTF16LE
or
$ ./configure --prefix=/usr --libdir=/usr/lib64 --sysconfdir=/etc --enable-gui=no --enable-drivers=no
--enable-iconv --with-iconv-char-enc=UTF8 --with-iconv-ucode-enc=UTF16LE
$ make
$ su (change to root)
# make install
After installing, then create symbolic link to installed unxiODBC files:
# cd /usr/lib64
# ln -s ./libodbcinst.so.2.0.0 ./libodbcinst.so.1
# ln -s ./libodbc.so.2.0.0 ./libodbc.so.1
# ln -s ./libodbccr.so.2.0.0 ./libodbccr.so.1
Note
If you want to build out a 32-bit unixODBC library, it could use the configuration:
# ./configure --prefix=/usr --libdir=/usr/lib64 --sysconfdir=/etc --enable-iconv --with-iconv-char-enc=UTF8
--with-iconv-ucode-enc=UTF16LE --enable-gui=no --enable-drivers=no CFLAGS=-m32 LDFLAGS=-m32
CXXFLAGS=-m32
, the GCC compiler MUST support to build 32-bit software, or it will generate error!
Qt is Cute!
Qt is Cute!
5) After installing unixODBC library, it could use uniODBC command “odbcinst -j“ to view current unixODBC
library configuration.
The information about the location of unixODBC configuration files, odbc.ini and odbcinst.ini, could be
changed through environment variables ODBCINI (for odbc.ini) and ODBCSYSINI (for odbcinst.ini).
# export ODBCINI=.
# export ODBCSYSINI=.
Run command “odbcinst -j“ to show the path to the unixODBC configuration files.
One unixODBC utility, odbc_config, could be used to display paths to library headers and library SO file, this
could be used in compiling application or library using unixODBC library.
Qt is Cute!
Qt is Cute!
Qt is Cute!
Qt is Cute!
Install MS SQL Server ODBC Driver/Tool
Reference - https://technet.microsoft.com/en-us/library/hh568451(v=sql.110).aspx
1) Download MS SQL Server ODBC driver for RedHat 6 from the official site:
http://www.microsoft.com/en-us/download/details.aspx?id=36437
In this Web site, chek “RedHat6msodbcsql-11.0.2270.0.tar.gz” item.
2) Unpack MS SQL Server ODBC driver for RedHat 6 archive, it will generate a folder named
msodbcsql-11.0.2270.0 :
$ tar zxvf msodbcsql-11.0.2270.0.tar.gz
3) Enter msodbcsql-11.0.2270.0 folder, you could:
# run build_dm.sh shell script to build and install unixODBC 2.3.0 driver manager
(this is optional, you could build your unixODBC dirver manager whose version is greater than or equal to
Qt is Cute!
Qt is Cute!
v2.3.0)
# run install.sh shell script to install MS SQL Server ODBC driver.
Cause it had installed unixODBC v2.3.4, so just run install.sh shell script. Note that it needs root role to run
install.sh shell script. Run the command:
$ su (change to root)
# ./install.sh install --force
Enter “YES” to agree this license.
0
Qt is Cute!
Qt is Cute!
After installing the driver, it could know the driver install path by view
/tmp/msodbcsql.1764.10794.25272/install.log file.
4) To see the MS SQL Server tool sqlcmd installation path.
5) To use the MS SQL Server sqlcmd utility:
sqlcmd -S ServerName,ServerPort -U UserName -P Password -d DatabaseName
Ex:
sqlcmd -S 192.168.2.110,1433 -U william -P 1234 -d Test
If it could connect to MS SQL Server successfully, it wil show prompt “1>.” Under this prompt, you could enter
SQL statements and then type “go” to execute SQL statements. Below is an example for getting the version of
MS SQL Server.
Below is another example that runs “sp_help” to query T-SQL syntax:
Note
When installing MS SQL ODBC driver, if it shows it can not find
unixODBC library, it could add library searching path by the steps:
1) # su (change to root)
1) Open /etc/ld.so.conf file using a text editor, add the line:
/usr/lib64
2) Save the file and run command in root role:
# ldconfig
Qt is Cute!
Qt is Cute!
For the usage of MS SQL sqlcmd utility, it could be found in below sites:
* https://msdn.microsoft.com/library/ms162773
* https://technet.microsoft.com/en-us/library/ms188247
* https://technet.microsoft.com/en-us/library/ms180944
* https://technet.microsoft.com/en-us/library/ms170207
* https://technet.microsoft.com/en-us/library/ms166559
Qt is Cute!
Qt is Cute!
Install Qt ODBC SQL Driver Plugin
The Qt official site for plugin and SQL driver:
* http://doc.qt.io/qt-5/linux-deployment.html
* http://doc.qt.io/qt-5/sql-driver.html
When using qt-opensource-linux-x64-5.4.1.run to install Qt5 library, the SQL ODBC driver plugin does not be built
(as below snapshot). If you want to have this kind of SQL driver plugin, you could follow below steps to build out.
Steps to build out Qt SQL driver plugin:
1) Download Qt-Base source archive from the Qt Web site and extract it.
$ wget http://download.qt.io/archive/qt/5.4/5.4.1/submodules/qtandroidextras-opensource-src-5.4.1.tar.xz
or
$ curl -O http://download.qt.io/archive/qt/5.4/5.4.1/submodules/qtandroidextras-opensource-src-5.4.1.tar.xz
2) Unpack Qt-Base source archive and it will generate a Qt-Base source folder named
qtandroidextras-opensource-src-5.4.1.
$ tar zxvf qtandroidextras-opensource-src-5.4.1.tar.xz
3) Enter ODBC driver source folder under Qt-Base source folder and build ODBC driver plugin using QMake.
$ cd ./qtandroidextras-opensource-src-5.4.1/src/plugins/sqldrivers/odbc
$ qmake
$ make
If there has no unixODBC library headers installed, it will generate error messages (as below snapshot) when
building ODBC SQL driver plugin.
Qt is Cute!
Qt is Cute!
After building successfully, the resulting plugin file, libqsqlodbc.so, locates in the folder:
qtandroidextras-opensource-src-5.4.1/plugins/sqldrivers/
4) Put the built out ODBC SQL driver plugin file into your installed Qt library folder.
Copy this plugin file to the same directory (plugins/sqldrivers) of your installed Qt library. Below is an example,
the install path is /home/william/Qt5.4.1, and the SQL driver plugin folder is gcc_64/plugins/sqldrivers.
For Qt application that using ODBC way to connect a database, if it could not find ODBC SQL driver plugin file,
libqsqlodbc.so, it will issue the error message as below snapshot:
The search path for Qt plugins (as well as a few other paths) is hard-coded into the QtCore library. By default, the
first plugin search path will be hard-coded as /intall-path-of-Qt/plugins.
All Qt GUI applications require a plugin that implements the Qt Platform Abstraction (QPA) layer in Qt 5. For
example, for Linux/X11, the name of the platform plugin is libqxcb.so. This plugin file MSUT be located within a
specific subdirectory (by default, platforms) under your distribution directory. Alternatively, it is possible to adjust
the search path Qt uses to find its plugins.
Be sure to distribute any Qt plugins that you need with your application. Similar to the platform plugin, each type
of plugin MUST be located within a specific subdirectory (such as imageformats or sqldrivers) within your
distribution directory.
Qt will search plugins in these path in sequence:
1. The installation path of Qt library.
2. The current folder of the executing Qt application.
Qt is Cute!
Qt is Cute!
The paths in below snapshot are:
1) “/home/william/Qt5.4.1/5.4/gcc_64/plugins” is the Qt library installation path
2) “/home/william/qt_proj/qsqldb” is the place where the Qt application locates in
, this example is for SQL driver plugin, so there must have a folder named “sqldrivers” in one of the two paths.
Qt is Cute!
Qt is Cute!
Creating an ODBC Data Source Name (DSN) for Linux
A Data Source Name (DSN) is the logical name that is used by Open Database Connectivity (ODBC) to refer to the
drive and other information that is required to access data.
unixODBC has two configuration file (.ini) for ODBC driver and DSN:
* /etc/odbcinst.ini
* /etc/odbc.ini
(Note that the INI file (.ini) installation path (here using “/etc”) could be changed when doing configuration of
unixODBC source file using the option --sysconfdir)
The format and usage of unixODBC configuration file could be found in the site:
http://www.unixodbc.org/odbcinst.html
/etc/odbcinst.ini is for setting up ODBC driver. The format is:
* The "Driver" attribute here tells the driver manager which shared object to load for the ODBC driver.
* The “Setup” attribute is the name/location of the shared object which provides a dialogue allowing you to
create/edit DSNs for this driver.
For example,
Note that MS SQL ODBC Driver for Linux prodies an unixODBC driver configuration sample file under the folder
/tmp/msodbcsql.1764.10794.25272/ after installing it successfully.
For DSN setup, /etc/odbc.ini is for System Source of DSN, ~/.odbc.ini is for User Source.
[ODBC Driver Name]
Description = The description of ODBC driver for 32-bit operating system.
Driver = Path to driver shared object for 32-bit operating system.
Setiup = Path to driver setup shared object for 32-bit operating system.
Driver64 = Path to driver shared object for 64-bit operating system.
Setiup64 = Path to driver setup shared object for 64-bit operating system.
Qt is Cute!
Qt is Cute!
The format for ODBC DSN is:
For example,
After configuring ODBC driver and data source name, it could unixODBC utility, isql, to verify the connection to
remote MS SQL Server.
To use the MS SQL Server isql utility:
isql -v MSSQL UserName Password
Ex:
isql -v MSSQL william 1234
If it could connect to the remote MS SQL Server successfully, it will show below prompt for you to execute SQL
statements.
If it add the option “-n”, it will show a new style prompt:
[ODBC Data Source Name]
Description = The description for this connection.
Driver = The ODBC driver name defined in odbcinst.ini file
Server = Database Server IP Address,PortNumer
User = The user name for database server connection
Password = The password for database server connection
Database = Database Name
Qt is Cute!
Qt is Cute!
If the user name and/or password is/are wrong, it will show below error message:
isql : <unixODBC Driver Load Error> - [ISQL]ERROR: Could not SQLConnect
If the ODBC driver could not be found or fails to be loaded, it will display below error message:
There has mail list for this problem, it could refer to unixODBC mail list and the IBM site to find more information .
* http://mailman.unixodbc.org/pipermail/unixodbc-support/2004-October/subject.html
* http://www-01.ibm.com/support/docview.wss?uid=swg21229860
[william@localhost ~]$ isql -v MSSQL william 1234
[IM004][unixODBC][Driver Manager]Driver's SQLAllocHandle on SQL_HANDLE_HENV failed [ISQL]ERROR: Could not
SQLConnect
Qt is Cute!
Qt is Cute!
unixODBC GUI Configuring Tool
unixODBC project provides a GUI tool for configure ODBC driver and DSN. This tool was written in Qt 4, so if you
want to compile it using Qt 5, it needs to do some porting stuffs that is described in Qt official site:
https://wiki.qt.io/Transition_from_Qt_4.x_to_Qt5
The unixODBC GUI tool source could be download from SVN server:
http://sourceforge.net/p/unixodbc-gui-qt/code/HEAD/tree/trunk/
The SVN command to check out source:
svn checkout http://svn.code.sf.net/p/unixodbc-gui-qt/code/trunk unixodbc-gui-qt-code
or
svn checkout svn://svn.code.sf.net/p/unixodbc-gui-qt/code/trunk unixodbc-gui-qt-code
Qt is Cute!
Qt is Cute!
Qt SQL Programming
The Qt official sites about SQL programming:
* http://doc.qt.io/qt-5/qtsql-index.html
* http://doc.qt.io/qt-5/sql-programming.html
* http://doc.qt.io/qt-5/examples-sql.html
There have SQL relavant examples under Qt SDK installation folder:
Qt-Intall-Path/5.4.1/Examples/Qt-5.4/sql/
The below two snapshots shows that using sqlbrowser example to verify the access to a remote MS SQL Server
through ODBC:
1) In database connection setting dialogue:
* Drop down Driver combolist item to QODBC or QODBC3,
* In Database Name field, fill the Data Source Name (DSN) defined in odbc.ini, described in the previous
chapter. The DSN used here is MSSQL.
* In Username and Password fields, fill the account and password to log on remote MS SQL Server.
These are set by MS SQL Server administrator in advance, so if you do not know this information for you,
please contact your MS SQL Server administrator.
Qt is Cute!
Qt is Cute!
2) If the ODBC connection could be created successfully, it will show table list under this ODBC connection node
on the righ “database” panel.
In “SQL Query” input panel, you could enter SQL query statement for testing.
If the SQL query is execute successfully, it will show “Query OK.” message on the status bar and the query
result would be shown on the panel near to “database” panel.
Qt is Cute!
Qt is Cute!
Below snapshots show the outputs of Qt SQL program usin Qt Core SQL library:
* Show a list tables in current database using Qt:
*Show the verison of MS SQL Server using Qt:
Qt is Cute!
Qt is Cute!
Reference
* http://stackoverflow.com/questions/14207088/qt-5-odbc-driver-issue
* http://www.freetds.org/userguide/qt.htm
* http://www.freetds.org/userguide/uodbc.htm
* https://blog.afoolishmanifesto.com/posts/install-and-configure-the-ms-odbc-driver-on-debian/
* https://jazz.net/forum/questions/57326/64-bit-odbc-driver-support-for-linux
* http://lifeofageekadmin.com/install-microsoft-sql-drivers-unixodbc-2-3-0-rhel-6-64-bit/
* http://webdev.blogs.southwales.ac.uk/2011/08/04/32-bit-odbc-driver-with-32-bit-unixodbc-on-a-64-bit-ubuntu-os/
* http://www.kognitio.com/forums/Installing%20Microsoft%20SQL%20Server%20Linux%20ODBC%20Driver.pdf
* http://www.easysoft.com/developer/interfaces/odbc/linux.html

More Related Content

What's hot (20)

PPTX
Introducing type script
Remo Jansen
 
PDF
TypeScript Best Practices
felixbillon
 
PPTX
Webpack Introduction
Anjali Chawla
 
PPTX
JAVASCRIPT PPT [Autosaved].pptx
AchieversIT
 
PPTX
XML Document Object Model (DOM)
BOSS Webtech
 
PPTX
Css selectors
Dinesh Kumar
 
PDF
React Router: React Meetup XXL
Rob Gietema
 
PDF
[부스트캠퍼세미나]조성동_야_너두_TDD_할_수_있어
CONNECT FOUNDATION
 
PDF
Svelte JS introduction
Mikhail Kuznetcov
 
PPTX
TypeScript Overview
Aniruddha Chakrabarti
 
PPTX
C++ Constructor and Destructors.pptx
sasukeman
 
PPTX
Understanding react hooks
Maulik Shah
 
PDF
Modern JavaScript Frameworks: Angular, React & Vue.js
Jonas Bandi
 
PDF
TypeScript Introduction
Dmitry Sheiko
 
PPT
JavaScript Tutorial
Bui Kiet
 
PDF
The New JavaScript: ES6
Rob Eisenberg
 
PPTX
ReactJS presentation.pptx
DivyanshGupta922023
 
PPTX
Program control statements in c#
Dr.Neeraj Kumar Pandey
 
PDF
Full Stack React Workshop [CSSC x GDSC]
GDSC UofT Mississauga
 
PDF
Introduction to Spring Boot
Trey Howard
 
Introducing type script
Remo Jansen
 
TypeScript Best Practices
felixbillon
 
Webpack Introduction
Anjali Chawla
 
JAVASCRIPT PPT [Autosaved].pptx
AchieversIT
 
XML Document Object Model (DOM)
BOSS Webtech
 
Css selectors
Dinesh Kumar
 
React Router: React Meetup XXL
Rob Gietema
 
[부스트캠퍼세미나]조성동_야_너두_TDD_할_수_있어
CONNECT FOUNDATION
 
Svelte JS introduction
Mikhail Kuznetcov
 
TypeScript Overview
Aniruddha Chakrabarti
 
C++ Constructor and Destructors.pptx
sasukeman
 
Understanding react hooks
Maulik Shah
 
Modern JavaScript Frameworks: Angular, React & Vue.js
Jonas Bandi
 
TypeScript Introduction
Dmitry Sheiko
 
JavaScript Tutorial
Bui Kiet
 
The New JavaScript: ES6
Rob Eisenberg
 
ReactJS presentation.pptx
DivyanshGupta922023
 
Program control statements in c#
Dr.Neeraj Kumar Pandey
 
Full Stack React Workshop [CSSC x GDSC]
GDSC UofT Mississauga
 
Introduction to Spring Boot
Trey Howard
 

Viewers also liked (20)

PDF
Usage Note of Apache Thrift for C++ Java PHP Languages
William Lee
 
PDF
Upgrade GCC & Install Qt 5.4 on CentOS 6.5
William Lee
 
PDF
Usage Note of SWIG for PHP
William Lee
 
PDF
Usage Notes of The Bro 2.2 / 2.3
William Lee
 
PDF
Android Services and Managers Basic
William Lee
 
PDF
GNOME GeoClue - The Geolocation Service in Gnome
William Lee
 
PDF
Android Debugging (Chinese)
William Lee
 
PDF
Moblin2 - Window Manager(Mutter) Plugin
William Lee
 
PDF
Android Storage - StorageManager & OBB
William Lee
 
PDF
CWMP TR-069 Training (Chinese)
William Lee
 
PDF
Introdunction To Network Management Protocols SNMP & TR-069
William Lee
 
PDF
Qt Development Tools
William Lee
 
PDF
Android Logging System
William Lee
 
PDF
Asterisk (IP-PBX) CDR Log Rotation
William Lee
 
PDF
IPv6 Overview
William Lee
 
PDF
MGCP Overview
William Lee
 
PDF
Android Storage - Internal and External Storages
William Lee
 
PDF
Introduction to SIP(Session Initiation Protocol)
William Lee
 
PDF
MTP & PTP
William Lee
 
PDF
Introdunction to Network Management Protocols - SNMP & TR-069
William Lee
 
Usage Note of Apache Thrift for C++ Java PHP Languages
William Lee
 
Upgrade GCC & Install Qt 5.4 on CentOS 6.5
William Lee
 
Usage Note of SWIG for PHP
William Lee
 
Usage Notes of The Bro 2.2 / 2.3
William Lee
 
Android Services and Managers Basic
William Lee
 
GNOME GeoClue - The Geolocation Service in Gnome
William Lee
 
Android Debugging (Chinese)
William Lee
 
Moblin2 - Window Manager(Mutter) Plugin
William Lee
 
Android Storage - StorageManager & OBB
William Lee
 
CWMP TR-069 Training (Chinese)
William Lee
 
Introdunction To Network Management Protocols SNMP & TR-069
William Lee
 
Qt Development Tools
William Lee
 
Android Logging System
William Lee
 
Asterisk (IP-PBX) CDR Log Rotation
William Lee
 
IPv6 Overview
William Lee
 
MGCP Overview
William Lee
 
Android Storage - Internal and External Storages
William Lee
 
Introduction to SIP(Session Initiation Protocol)
William Lee
 
MTP & PTP
William Lee
 
Introdunction to Network Management Protocols - SNMP & TR-069
William Lee
 
Ad

Similar to Usage Note of Qt ODBC Database Access on Linux (20)

PDF
Steps to Create odbc connection linux
Osama Mustafa
 
DOCX
Connect sql-using-perl-from-linux
Venkat Raman
 
PDF
Teradata client4
Madhu Bandi
 
PPTX
Sql session qt cs
AndreSomers
 
PDF
Squeak DBX
ESUG
 
PDF
The Ring programming language version 1.3 book - Part 19 of 88
Mahmoud Samir Fayed
 
PDF
The best Teradata RDBMS introduction a quick refresher
Srinimf-Slides
 
PPTX
BI, Integration, and Apps on Couchbase using Simba ODBC and JDBC
Simba Technologies
 
PPT
Dbms & prog lang
Tech_MX
 
PPT
Libmysqld Introduction
papablues
 
PDF
The Ring programming language version 1.5.2 book - Part 27 of 181
Mahmoud Samir Fayed
 
PPTX
How to add stuff to MySQL
Georgi Kodinov
 
PDF
The Ring programming language version 1.2 book - Part 17 of 84
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.9 book - Part 35 of 210
Mahmoud Samir Fayed
 
PPT
Perl DBI Scripting with the ILS
Roy Zimmer
 
PPTX
SQLcl overview - A new Command Line Interface for Oracle Database
Jeff Smith
 
PDF
The Ring programming language version 1.10 book - Part 36 of 212
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.5.4 book - Part 28 of 185
Mahmoud Samir Fayed
 
ODP
Award-winning technology: Oxid loves the query cache
Ulf Wendel
 
PDF
Ibi Open Visualizations
Clif Kranish
 
Steps to Create odbc connection linux
Osama Mustafa
 
Connect sql-using-perl-from-linux
Venkat Raman
 
Teradata client4
Madhu Bandi
 
Sql session qt cs
AndreSomers
 
Squeak DBX
ESUG
 
The Ring programming language version 1.3 book - Part 19 of 88
Mahmoud Samir Fayed
 
The best Teradata RDBMS introduction a quick refresher
Srinimf-Slides
 
BI, Integration, and Apps on Couchbase using Simba ODBC and JDBC
Simba Technologies
 
Dbms & prog lang
Tech_MX
 
Libmysqld Introduction
papablues
 
The Ring programming language version 1.5.2 book - Part 27 of 181
Mahmoud Samir Fayed
 
How to add stuff to MySQL
Georgi Kodinov
 
The Ring programming language version 1.2 book - Part 17 of 84
Mahmoud Samir Fayed
 
The Ring programming language version 1.9 book - Part 35 of 210
Mahmoud Samir Fayed
 
Perl DBI Scripting with the ILS
Roy Zimmer
 
SQLcl overview - A new Command Line Interface for Oracle Database
Jeff Smith
 
The Ring programming language version 1.10 book - Part 36 of 212
Mahmoud Samir Fayed
 
The Ring programming language version 1.5.4 book - Part 28 of 185
Mahmoud Samir Fayed
 
Award-winning technology: Oxid loves the query cache
Ulf Wendel
 
Ibi Open Visualizations
Clif Kranish
 
Ad

More from William Lee (16)

PDF
Viewing Android Source Files in Eclipse (Chinese)
William Lee
 
PDF
Usage Note of Microsoft Dependency Walker
William Lee
 
PDF
Usage Note of PlayCap
William Lee
 
PDF
Qt4 App - Sliding Window
William Lee
 
PDF
GTK+ 2.0 App - Desktop App Chooser
William Lee
 
PDF
GTK+ 2.0 App - Icon Chooser
William Lee
 
PDF
Note of CGI and ASP
William Lee
 
PDF
L.A.M.P Installation Note --- CentOS 6.5
William Lee
 
PDF
C Program Runs on Wrong Target Platform(CPU Architecture)
William Lee
 
PDF
Internationalization(i18n) of Web Page
William Lee
 
PDF
Notes for SQLite3 Usage
William Lee
 
PDF
Cygwin Install How-To (Chinese)
William Lee
 
PDF
Study of Chromium OS
William Lee
 
PDF
More Details about TR-069 (CPE WAN Management Protocol)
William Lee
 
PDF
Qt Animation
William Lee
 
PDF
Android Storage - Vold
William Lee
 
Viewing Android Source Files in Eclipse (Chinese)
William Lee
 
Usage Note of Microsoft Dependency Walker
William Lee
 
Usage Note of PlayCap
William Lee
 
Qt4 App - Sliding Window
William Lee
 
GTK+ 2.0 App - Desktop App Chooser
William Lee
 
GTK+ 2.0 App - Icon Chooser
William Lee
 
Note of CGI and ASP
William Lee
 
L.A.M.P Installation Note --- CentOS 6.5
William Lee
 
C Program Runs on Wrong Target Platform(CPU Architecture)
William Lee
 
Internationalization(i18n) of Web Page
William Lee
 
Notes for SQLite3 Usage
William Lee
 
Cygwin Install How-To (Chinese)
William Lee
 
Study of Chromium OS
William Lee
 
More Details about TR-069 (CPE WAN Management Protocol)
William Lee
 
Qt Animation
William Lee
 
Android Storage - Vold
William Lee
 

Recently uploaded (20)

PPTX
Agentforce World Tour Toronto '25 - Supercharge MuleSoft Development with Mod...
Alexandra N. Martinez
 
PDF
“Computer Vision at Sea: Automated Fish Tracking for Sustainable Fishing,” a ...
Edge AI and Vision Alliance
 
PDF
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
PDF
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
PPTX
MuleSoft MCP Support (Model Context Protocol) and Use Case Demo
shyamraj55
 
PDF
UPDF - AI PDF Editor & Converter Key Features
DealFuel
 
DOCX
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
PDF
LOOPS in C Programming Language - Technology
RishabhDwivedi43
 
PDF
Kit-Works Team Study_20250627_한달만에만든사내서비스키링(양다윗).pdf
Wonjun Hwang
 
PDF
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
PDF
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
PDF
ICONIQ State of AI Report 2025 - The Builder's Playbook
Razin Mustafiz
 
PDF
NLJUG Speaker academy 2025 - first session
Bert Jan Schrijver
 
PDF
Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
PPTX
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
PDF
Automating Feature Enrichment and Station Creation in Natural Gas Utility Net...
Safe Software
 
PDF
AI Agents in the Cloud: The Rise of Agentic Cloud Architecture
Lilly Gracia
 
PDF
UiPath DevConnect 2025: Agentic Automation Community User Group Meeting
DianaGray10
 
PPTX
Agentforce World Tour Toronto '25 - MCP with MuleSoft
Alexandra N. Martinez
 
PPTX
Digital Circuits, important subject in CS
contactparinay1
 
Agentforce World Tour Toronto '25 - Supercharge MuleSoft Development with Mod...
Alexandra N. Martinez
 
“Computer Vision at Sea: Automated Fish Tracking for Sustainable Fishing,” a ...
Edge AI and Vision Alliance
 
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
MuleSoft MCP Support (Model Context Protocol) and Use Case Demo
shyamraj55
 
UPDF - AI PDF Editor & Converter Key Features
DealFuel
 
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
LOOPS in C Programming Language - Technology
RishabhDwivedi43
 
Kit-Works Team Study_20250627_한달만에만든사내서비스키링(양다윗).pdf
Wonjun Hwang
 
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
ICONIQ State of AI Report 2025 - The Builder's Playbook
Razin Mustafiz
 
NLJUG Speaker academy 2025 - first session
Bert Jan Schrijver
 
Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
Automating Feature Enrichment and Station Creation in Natural Gas Utility Net...
Safe Software
 
AI Agents in the Cloud: The Rise of Agentic Cloud Architecture
Lilly Gracia
 
UiPath DevConnect 2025: Agentic Automation Community User Group Meeting
DianaGray10
 
Agentforce World Tour Toronto '25 - MCP with MuleSoft
Alexandra N. Martinez
 
Digital Circuits, important subject in CS
contactparinay1
 

Usage Note of Qt ODBC Database Access on Linux

  • 1. Qt is Cute! Qt is Cute! Usage Note of Qt ODBC Database Access On Linux William.L [email protected] 2015-10-05
  • 2. Qt is Cute! Qt is Cute! Index What is ODBC? ............................................................................................................................................................ 3 Environment................................................................................................................................................................ 4 Install unixODBC Driver/Library/Tool......................................................................................................................... 5 Install MS SQL Server ODBC Driver/Tool.................................................................................................................... 9 Install Qt ODBC SQL Driver Plugin ............................................................................................................................ 13 Creating an ODBC Data Source Name (DSN) for Linux............................................................................................. 16 unixODBC GUI Configuring Tool........................................................................................................................ 19 Qt SQL Programming................................................................................................................................................. 20 Reference................................................................................................................................................................... 23
  • 3. Qt is Cute! Qt is Cute! What is ODBC? ODBC is the acronym for Open DataBase Connectivity, a Microsoft Universal Data Access standard that started life as the Windows implementation of the X/Open SQL Call Level Interface specification. Since its inception in 1992 it has rapidly become the industry standard interface for developing database independent applications. Example codes using Qt Core SQL library and relavant reference for this documentation could be downloaded from the GitHub: https://github.com/wiliwe/qt-sql-odbc-prog-example
  • 4. Qt is Cute! Qt is Cute! Environment * Linux CentOS 6.5 64-bit (upgraded to 6.7) * Qt v5.4.1 * Qt Creator v3.3.1 * unixODBC library v2.3.4 (built out from source file) * Microsoft SQL Server ODBC driver for RedHat 6 The relationship/architecture of the softwares used for the access of MS SQL Server through ODBC driver is shown as below block diagram: Cause to that unixODBC library is depended by MS SQL Server ODBC driver for Linux and Qt SQL driver plugin, so the first software to be installed is unixODBC library. Linux CentOS 6.5 MS Windows MS SQL Server Qt Application MS SQL Server ODBC Driver For RedHat Qt ODBC Driver Plug-in unixODBC Driver Manager odbc.ini odbcinst.ini Qt Core Library IP network
  • 5. Qt is Cute! Qt is Cute! Install unixODBC Driver/Library/Tool On Unix/Linux system, it is recommended that you use unixODBC library (http://www.unixodbc.org). Qt SQL ODBC driver plugin depends on it, so you need the unixODBC header files and shared libraries. 1) First of all, remove all installed unixODBC libraries and tools in the system. # su (change to root) $ yum erase unixodbc* 2) Download unixODBC source archive from one of below sites: * http://www.unixodbc.org/download.html * ftp://ftp.unixodbc.org/pub/unixODBC/ Here using v2.3.4, the source archive file is unixODBC-2.3.4.tar.gz. Note: There are two open source ODBC driver managers for UNIX/Linux systems: * unixODBC User Manual http://www.unixodbc.org/doc/ * iODBC http://www.iodbc.org/dataspace/iodbc/wiki/iODBC/
  • 6. Qt is Cute! Qt is Cute! 3) Unpack the source archive and it will create a folder named unixODBC-2.3.4. $ tar zxvf unixODBC-2.3.4.tar.gz 4) Enter the unixODBC-2.3.4 folder and run commands: $ ./configure --prefix=/usr --libdir=/usr/lib64 --sysconfdir=/etc --disable-gui --disable-drivers --enable-stats=no --enable-iconv --with-iconv-char-enc=UTF8 --with-iconv-ucode-enc=UTF16LE or $ ./configure --prefix=/usr --libdir=/usr/lib64 --sysconfdir=/etc --enable-gui=no --enable-drivers=no --enable-iconv --with-iconv-char-enc=UTF8 --with-iconv-ucode-enc=UTF16LE $ make $ su (change to root) # make install After installing, then create symbolic link to installed unxiODBC files: # cd /usr/lib64 # ln -s ./libodbcinst.so.2.0.0 ./libodbcinst.so.1 # ln -s ./libodbc.so.2.0.0 ./libodbc.so.1 # ln -s ./libodbccr.so.2.0.0 ./libodbccr.so.1 Note If you want to build out a 32-bit unixODBC library, it could use the configuration: # ./configure --prefix=/usr --libdir=/usr/lib64 --sysconfdir=/etc --enable-iconv --with-iconv-char-enc=UTF8 --with-iconv-ucode-enc=UTF16LE --enable-gui=no --enable-drivers=no CFLAGS=-m32 LDFLAGS=-m32 CXXFLAGS=-m32 , the GCC compiler MUST support to build 32-bit software, or it will generate error!
  • 7. Qt is Cute! Qt is Cute! 5) After installing unixODBC library, it could use uniODBC command “odbcinst -j“ to view current unixODBC library configuration. The information about the location of unixODBC configuration files, odbc.ini and odbcinst.ini, could be changed through environment variables ODBCINI (for odbc.ini) and ODBCSYSINI (for odbcinst.ini). # export ODBCINI=. # export ODBCSYSINI=. Run command “odbcinst -j“ to show the path to the unixODBC configuration files. One unixODBC utility, odbc_config, could be used to display paths to library headers and library SO file, this could be used in compiling application or library using unixODBC library.
  • 8. Qt is Cute! Qt is Cute!
  • 9. Qt is Cute! Qt is Cute! Install MS SQL Server ODBC Driver/Tool Reference - https://technet.microsoft.com/en-us/library/hh568451(v=sql.110).aspx 1) Download MS SQL Server ODBC driver for RedHat 6 from the official site: http://www.microsoft.com/en-us/download/details.aspx?id=36437 In this Web site, chek “RedHat6msodbcsql-11.0.2270.0.tar.gz” item. 2) Unpack MS SQL Server ODBC driver for RedHat 6 archive, it will generate a folder named msodbcsql-11.0.2270.0 : $ tar zxvf msodbcsql-11.0.2270.0.tar.gz 3) Enter msodbcsql-11.0.2270.0 folder, you could: # run build_dm.sh shell script to build and install unixODBC 2.3.0 driver manager (this is optional, you could build your unixODBC dirver manager whose version is greater than or equal to
  • 10. Qt is Cute! Qt is Cute! v2.3.0) # run install.sh shell script to install MS SQL Server ODBC driver. Cause it had installed unixODBC v2.3.4, so just run install.sh shell script. Note that it needs root role to run install.sh shell script. Run the command: $ su (change to root) # ./install.sh install --force Enter “YES” to agree this license. 0
  • 11. Qt is Cute! Qt is Cute! After installing the driver, it could know the driver install path by view /tmp/msodbcsql.1764.10794.25272/install.log file. 4) To see the MS SQL Server tool sqlcmd installation path. 5) To use the MS SQL Server sqlcmd utility: sqlcmd -S ServerName,ServerPort -U UserName -P Password -d DatabaseName Ex: sqlcmd -S 192.168.2.110,1433 -U william -P 1234 -d Test If it could connect to MS SQL Server successfully, it wil show prompt “1>.” Under this prompt, you could enter SQL statements and then type “go” to execute SQL statements. Below is an example for getting the version of MS SQL Server. Below is another example that runs “sp_help” to query T-SQL syntax: Note When installing MS SQL ODBC driver, if it shows it can not find unixODBC library, it could add library searching path by the steps: 1) # su (change to root) 1) Open /etc/ld.so.conf file using a text editor, add the line: /usr/lib64 2) Save the file and run command in root role: # ldconfig
  • 12. Qt is Cute! Qt is Cute! For the usage of MS SQL sqlcmd utility, it could be found in below sites: * https://msdn.microsoft.com/library/ms162773 * https://technet.microsoft.com/en-us/library/ms188247 * https://technet.microsoft.com/en-us/library/ms180944 * https://technet.microsoft.com/en-us/library/ms170207 * https://technet.microsoft.com/en-us/library/ms166559
  • 13. Qt is Cute! Qt is Cute! Install Qt ODBC SQL Driver Plugin The Qt official site for plugin and SQL driver: * http://doc.qt.io/qt-5/linux-deployment.html * http://doc.qt.io/qt-5/sql-driver.html When using qt-opensource-linux-x64-5.4.1.run to install Qt5 library, the SQL ODBC driver plugin does not be built (as below snapshot). If you want to have this kind of SQL driver plugin, you could follow below steps to build out. Steps to build out Qt SQL driver plugin: 1) Download Qt-Base source archive from the Qt Web site and extract it. $ wget http://download.qt.io/archive/qt/5.4/5.4.1/submodules/qtandroidextras-opensource-src-5.4.1.tar.xz or $ curl -O http://download.qt.io/archive/qt/5.4/5.4.1/submodules/qtandroidextras-opensource-src-5.4.1.tar.xz 2) Unpack Qt-Base source archive and it will generate a Qt-Base source folder named qtandroidextras-opensource-src-5.4.1. $ tar zxvf qtandroidextras-opensource-src-5.4.1.tar.xz 3) Enter ODBC driver source folder under Qt-Base source folder and build ODBC driver plugin using QMake. $ cd ./qtandroidextras-opensource-src-5.4.1/src/plugins/sqldrivers/odbc $ qmake $ make If there has no unixODBC library headers installed, it will generate error messages (as below snapshot) when building ODBC SQL driver plugin.
  • 14. Qt is Cute! Qt is Cute! After building successfully, the resulting plugin file, libqsqlodbc.so, locates in the folder: qtandroidextras-opensource-src-5.4.1/plugins/sqldrivers/ 4) Put the built out ODBC SQL driver plugin file into your installed Qt library folder. Copy this plugin file to the same directory (plugins/sqldrivers) of your installed Qt library. Below is an example, the install path is /home/william/Qt5.4.1, and the SQL driver plugin folder is gcc_64/plugins/sqldrivers. For Qt application that using ODBC way to connect a database, if it could not find ODBC SQL driver plugin file, libqsqlodbc.so, it will issue the error message as below snapshot: The search path for Qt plugins (as well as a few other paths) is hard-coded into the QtCore library. By default, the first plugin search path will be hard-coded as /intall-path-of-Qt/plugins. All Qt GUI applications require a plugin that implements the Qt Platform Abstraction (QPA) layer in Qt 5. For example, for Linux/X11, the name of the platform plugin is libqxcb.so. This plugin file MSUT be located within a specific subdirectory (by default, platforms) under your distribution directory. Alternatively, it is possible to adjust the search path Qt uses to find its plugins. Be sure to distribute any Qt plugins that you need with your application. Similar to the platform plugin, each type of plugin MUST be located within a specific subdirectory (such as imageformats or sqldrivers) within your distribution directory. Qt will search plugins in these path in sequence: 1. The installation path of Qt library. 2. The current folder of the executing Qt application.
  • 15. Qt is Cute! Qt is Cute! The paths in below snapshot are: 1) “/home/william/Qt5.4.1/5.4/gcc_64/plugins” is the Qt library installation path 2) “/home/william/qt_proj/qsqldb” is the place where the Qt application locates in , this example is for SQL driver plugin, so there must have a folder named “sqldrivers” in one of the two paths.
  • 16. Qt is Cute! Qt is Cute! Creating an ODBC Data Source Name (DSN) for Linux A Data Source Name (DSN) is the logical name that is used by Open Database Connectivity (ODBC) to refer to the drive and other information that is required to access data. unixODBC has two configuration file (.ini) for ODBC driver and DSN: * /etc/odbcinst.ini * /etc/odbc.ini (Note that the INI file (.ini) installation path (here using “/etc”) could be changed when doing configuration of unixODBC source file using the option --sysconfdir) The format and usage of unixODBC configuration file could be found in the site: http://www.unixodbc.org/odbcinst.html /etc/odbcinst.ini is for setting up ODBC driver. The format is: * The "Driver" attribute here tells the driver manager which shared object to load for the ODBC driver. * The “Setup” attribute is the name/location of the shared object which provides a dialogue allowing you to create/edit DSNs for this driver. For example, Note that MS SQL ODBC Driver for Linux prodies an unixODBC driver configuration sample file under the folder /tmp/msodbcsql.1764.10794.25272/ after installing it successfully. For DSN setup, /etc/odbc.ini is for System Source of DSN, ~/.odbc.ini is for User Source. [ODBC Driver Name] Description = The description of ODBC driver for 32-bit operating system. Driver = Path to driver shared object for 32-bit operating system. Setiup = Path to driver setup shared object for 32-bit operating system. Driver64 = Path to driver shared object for 64-bit operating system. Setiup64 = Path to driver setup shared object for 64-bit operating system.
  • 17. Qt is Cute! Qt is Cute! The format for ODBC DSN is: For example, After configuring ODBC driver and data source name, it could unixODBC utility, isql, to verify the connection to remote MS SQL Server. To use the MS SQL Server isql utility: isql -v MSSQL UserName Password Ex: isql -v MSSQL william 1234 If it could connect to the remote MS SQL Server successfully, it will show below prompt for you to execute SQL statements. If it add the option “-n”, it will show a new style prompt: [ODBC Data Source Name] Description = The description for this connection. Driver = The ODBC driver name defined in odbcinst.ini file Server = Database Server IP Address,PortNumer User = The user name for database server connection Password = The password for database server connection Database = Database Name
  • 18. Qt is Cute! Qt is Cute! If the user name and/or password is/are wrong, it will show below error message: isql : <unixODBC Driver Load Error> - [ISQL]ERROR: Could not SQLConnect If the ODBC driver could not be found or fails to be loaded, it will display below error message: There has mail list for this problem, it could refer to unixODBC mail list and the IBM site to find more information . * http://mailman.unixodbc.org/pipermail/unixodbc-support/2004-October/subject.html * http://www-01.ibm.com/support/docview.wss?uid=swg21229860 [william@localhost ~]$ isql -v MSSQL william 1234 [IM004][unixODBC][Driver Manager]Driver's SQLAllocHandle on SQL_HANDLE_HENV failed [ISQL]ERROR: Could not SQLConnect
  • 19. Qt is Cute! Qt is Cute! unixODBC GUI Configuring Tool unixODBC project provides a GUI tool for configure ODBC driver and DSN. This tool was written in Qt 4, so if you want to compile it using Qt 5, it needs to do some porting stuffs that is described in Qt official site: https://wiki.qt.io/Transition_from_Qt_4.x_to_Qt5 The unixODBC GUI tool source could be download from SVN server: http://sourceforge.net/p/unixodbc-gui-qt/code/HEAD/tree/trunk/ The SVN command to check out source: svn checkout http://svn.code.sf.net/p/unixodbc-gui-qt/code/trunk unixodbc-gui-qt-code or svn checkout svn://svn.code.sf.net/p/unixodbc-gui-qt/code/trunk unixodbc-gui-qt-code
  • 20. Qt is Cute! Qt is Cute! Qt SQL Programming The Qt official sites about SQL programming: * http://doc.qt.io/qt-5/qtsql-index.html * http://doc.qt.io/qt-5/sql-programming.html * http://doc.qt.io/qt-5/examples-sql.html There have SQL relavant examples under Qt SDK installation folder: Qt-Intall-Path/5.4.1/Examples/Qt-5.4/sql/ The below two snapshots shows that using sqlbrowser example to verify the access to a remote MS SQL Server through ODBC: 1) In database connection setting dialogue: * Drop down Driver combolist item to QODBC or QODBC3, * In Database Name field, fill the Data Source Name (DSN) defined in odbc.ini, described in the previous chapter. The DSN used here is MSSQL. * In Username and Password fields, fill the account and password to log on remote MS SQL Server. These are set by MS SQL Server administrator in advance, so if you do not know this information for you, please contact your MS SQL Server administrator.
  • 21. Qt is Cute! Qt is Cute! 2) If the ODBC connection could be created successfully, it will show table list under this ODBC connection node on the righ “database” panel. In “SQL Query” input panel, you could enter SQL query statement for testing. If the SQL query is execute successfully, it will show “Query OK.” message on the status bar and the query result would be shown on the panel near to “database” panel.
  • 22. Qt is Cute! Qt is Cute! Below snapshots show the outputs of Qt SQL program usin Qt Core SQL library: * Show a list tables in current database using Qt: *Show the verison of MS SQL Server using Qt:
  • 23. Qt is Cute! Qt is Cute! Reference * http://stackoverflow.com/questions/14207088/qt-5-odbc-driver-issue * http://www.freetds.org/userguide/qt.htm * http://www.freetds.org/userguide/uodbc.htm * https://blog.afoolishmanifesto.com/posts/install-and-configure-the-ms-odbc-driver-on-debian/ * https://jazz.net/forum/questions/57326/64-bit-odbc-driver-support-for-linux * http://lifeofageekadmin.com/install-microsoft-sql-drivers-unixodbc-2-3-0-rhel-6-64-bit/ * http://webdev.blogs.southwales.ac.uk/2011/08/04/32-bit-odbc-driver-with-32-bit-unixodbc-on-a-64-bit-ubuntu-os/ * http://www.kognitio.com/forums/Installing%20Microsoft%20SQL%20Server%20Linux%20ODBC%20Driver.pdf * http://www.easysoft.com/developer/interfaces/odbc/linux.html