- Introduction
The Big SQL odbc driver is available on Linux 32bit and 64bit versions. The Big SQL client package contains the 32-bit driver in the 'x86' directory and 64-bit driver in the 'x86_64' directory.
- Driver Installation
Extract the 32bit driver available in ‘x86’ folder or 64bit driver available in ‘x86_64’ folder at desired location.
- Directory structure
The following three directories exist
lib - runtime library file
include – header files to be used to compile client applications
cfg – configuration file (odbc.ini)
README - Refer Readme.txt to configure OpenSSL library.
- OpenSSL library configuration
Install the openssl<version> package if it is missing from the operating system installation media.
a) Issue the following command as the root user:
i. if using a 64 bit machine:
cd /lib64
ii. if using a 32 bit machine:
cd /lib
b) Check that the libssl.so.<version> file exists.
c) Create soft links as shown below:
ln -s libssl.so.<version> libssl.so.6
d) Check to see the soft link is created as below:
ls -l libssl*
libssl.so.6 -> libssl.so.<version>
For example, if the libssl version is 1.0.0 (libssl.so.1.0.0), create the soft link as below:
ln -s libssl.so.1.0.0 libssl.so.6
ls -l libssl*
libssl.so.6 -> libssl.so.1.0.0
- Configuration of Big SQL ODBC driver
The odbc.ini file is used to configure the Big SQL odbc driver.
The odbc.ini is located at the below mentioned location
32 bit driver
INSTALL_PATH/x86/cfg/odbc.ini
64 bit driver
INSTALL_PATH/x86_64/cfg/odbc.ini
INSTALL_PATH : The path where the driver package is extracted.
odbc.ini file example
[dsnsample]
DATABASE=sampledb
HOST=sample.host.com
PORT=9812
UID=<uid>
PWD=<pwd>
- Set library path
Export the shared library path to additionally include the Big SQL ODBC library.
export LD_LIBRARY_PATH=</odbc/driver/lib/path>
E.g.
export LD_LIBRARY_PATH =/home/odbc/x86/lib
export LD_LIBRARY_PATH =/home/odbc/x86_64/lib
- Sample application
#include <stdio.h>
#include <sqlext.h>
#include <sql.h>
#include <string.h>
#include <stdlib.h>
int main(int argc, char**argv){
SQLRETURN rc = SQL_SUCCESS;
SQLHENV env = NULL;
SQLHDBC dbc = NULL;
SQLHSTMT stmt = NULL;
// allocate env handle
rc = SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &env);
rc = SQLSetEnvAttr(env, SQL_ATTR_ODBC_VERSION, (void *) SQL_OV_ODBC3, 0);
// allocate connection handle
rc = SQLAllocHandle(SQL_HANDLE_DBC, env, &dbc);
// allocate statement handle
rc = SQLAllocHandle(SQL_HANDLE_STMT, dbc, &stmt);
// connect
rc = SQLDriverConnect(dbc, NULL, (SQLCHAR*)connstr, SQL_NTS, NULL, 0, NULL, SQL_DRIVER_COMPLETE);
if (rc == SQL_SUCCESS) {
printf ("\nconnection success..\n");
}
// query execution
rc = SQLExecDirect(stmt, (SQLCHAR*)query, SQL_NTS);
rc = SQLNumResultCols(stmt, &numResults);
rc = SQLBindCol(stmt, 1, SQL_C_CHAR, name, sizeof(name), &nameLength);
rc = SQLFetch(stmt);
while (rc != SQL_NO_DATA_FOUND) {
cout << "Value for name: " << name << endl;
rc = SQLFetch(stmt);
if ( rc != SQL_NO_DATA_FOUND) {
cout << "Fetch(2)" << endl;
}
}
if (stmt) {
SQLFreeHandle(SQL_HANDLE_STMT, stmt); stmt = NULL; }
if (dbc) {
SQLFreeHandle(SQL_HANDLE_DBC, dbc); dbc = NULL; }
if (env) {
SQLFreeHandle(SQL_HANDLE_ENV, env); env = NULL; }
return rc;
}
Sample make file
CC=g++
BIGSQLDIR=/home/odbc/x86_64
LDFLAGS=-L$(BIGSQLDIR)/lib -lbigsqlodbcclient -lbigsqlodbcwrapper
INCFLAGS=-I$(BIGSQLDIR)/include
CFLAGS= -g -c $(INCFLAGS)
all: sampleapp
sampleapp: sampleapp.o
$(CC) $(LDFLAGS) sampleapp.o -o $@
sampleapp.o: sampleapp.cpp
$(CC) $(CFLAGS) sampleapp.cpp -o $@
clean:
-rm sampleapp.o
-rm sampleapp
- Creating bigsql odbc driver log file
Add the DIAGLEVEL key word in the bigsql odbc driver odbc.ini file.
Eg:
Eg: odbc.ini at x86_64/cfg/odbc.ini
[COMMON]
DIAGLEVEL=1
It creates the diag.log file at x86_64/log/diag.log for 64bit driver, x86/log/diag.log for 32bit driver.
- Working with unixODBC driver manager
The bigsql odbc driver is tested using unixODBC 2.3.1 driver manager. The bigsql odbc driver is to be configured to work with unixODBC driver manager.
- Add the DSN entry in the bigsql odbc driver odbc.ini file
Eg: odbc.ini at x86_64/cfg/odbc.ini
[dsnsample]
DATABASE=sampledb
HOST=sample.host.com
PORT=7052
UID=<uid>
PWD=<pwd>
export LD_LIBRARY_PATH =/home/odbc/x86_64/lib
- Provide the bigsql odbc library name in the odbc.ini file of unixODBC driver manager
The unixODBC driver manager has ini file at unixODBC/etc/odbc.ini. Edit the odbc.ini file as below
[dsnsample]
Driver=/home/x86_64/lib/libbigsqlodbcwrapper.so
here:
This dsn name is the dsn which is used by bigsql odbc driver.
By giving driver library unixodbc drive manager loads the bigsql odbc driver library.
- Run the unixodbc isql app
unixODBC/bin/isql -d mydsn <uid> <pwd>
$ ./isql dsnsample uid pwd
+---------------------------------------+
| Connected! |
| |
| sql-statement |
| help [tablename] |
| quit |
| |
+---------------------------------------+
SQL> select * from works;
| empnum | pnum | hours |
+-------------------------------------------------------------------------------------------------------+--------------------------+
| E1 | P1 | 40.000000 |
| E1 | P2 | 20.000000 |
SQLRowCount returns 11
11 rows fetched
SQL> quit;