Linux ODBC/MX Client Driver for SQL/MX Release 3.2.1 (H06.26+, J06.15+)
A Sample ODBC application
Compiling and linking the sample application
Use the g++ compiler to compile the application with the header files that are shipped along with
the Linux ODBC/MX Client Driver:
odbc]$ g++ -o < output object name > -I < location of the header files
shipped with the driver > \
< input file for compilation > -l mxodbc
Example for compiling a threaded application
The following is a sample compilation command for a threaded application:
odbc]$ /usr/bin/g++ -m32 -I <path for include files>
ThreadODBCTestAppl.c -o ThreadODBCTestAppl —l mxodbc
Testing the sample
To run the sample test application, issue any of the following commands on the bash shell:
odbc]$ ./ThreadODBCTestAppl <DS Name>
odbc]$ ./ThreadODBCTestAppl –help
Considerations:
• If the library is not present in the default location (/usr/lib), ensure that the location of the
driver (libmxodbc.so) is set in the environment variable LD_LIBRARY_PATH. To set the
LD_LIBRARY_PATH variable, enter the following command:
export LD_LIBRARY_PATH = < libmxodbc.so directory >
• Ensure that the MXODSN file is present in the same location as that of the sample application.
If not, ensure that the default MXODSN file is present in /etc/hpodbc directory or set
DSN_PATH to MXODSN location.
• To enable tracing, set the TraceStart attribute in the MXODSN file 1.
You must edit the MXODSN file to include your preferred DSN. Update all the mandatory fields for
the DSN.
Sample application code
/***************************************************************
*****
//
// @@@ START COPYRIGHT @@@
//
// Copyright 2007
//
// HP CONFIDENTIAL: NEED TO KNOW ONLY
//
// Copyright Hewlett-Packard Development Company, L.P.
// Protected as an unpublished work.
//
// The computer program listings, specifications and
// documentation herein are the property of Hewlett-Packard
// Development Company, L.P., or a third party supplier and
// shall not be reproduced, copied, disclosed, or used in whole
// or in part for any reason without the prior express written
// permission of Hewlett-Packard
// Development Company, L.P.
//
38 Sample ODBC application










