Configuring and Connecting on UNIX and Linux
The following basic information enables you to configure a data source and test connect with a driver immediately after installation.
Refer to "Configuring the Product on UNIX/Linux" of the DataDirect Connect for ODBC and Connect XE for ODBC User's Guide for detailed information about configuring the UNIX/Linux environment and data sources.
NOTE: In the following examples, xx in a driver filename stands for the driver level number.
Environment Setup
- Check your permissions: You should log in as a user with full r/w/x permissions recursively on the entire product installation directory.
- Determine which shell you are running by executing the env command.
- Run the DataDirect Technologies setup script to set variables. Two scripts, odbc.sh and odbc.csh, are installed in the installation directory. For Korn, Borne, and equivalent shells, execute odbc.sh. For a C shell, execute odbc.csh. After running the setup script, execute the env command to verify that the installation_directory/lib directory has been added to your shared library path.
- Set the ODBCINI environment variable. The variable should point to the path from the root directory to the system information file where your data source will reside. The system information file can have any name, but the product is installed with a default template file called odbc.ini in the product installation directory. For example, if you use an installation directory of /opt/odbc and the default system information file, from the Korn or Borne shell you would enter:
ODBCINI=/opt/odbc/odbc.ini; export ODBCINI
From the C shell, you would enter:
setenv ODBCINI /opt/odbc/odbc.ini
Test Loading the Driver
The ivtestlib tool, located in the installation_directory/bin directory, is a utility to verify that the driver can be loaded into memory. For example, to load a driver you might enter:
where
driver_shared_object_nameis the name of the specific driver file. For example, the MySQL Wire Protocol on Solaris is ivmysqlxx.so.An error message is returned if the load is not successful.
Configuring a Data Source in the System Information File
NOTE: Currently, you cannot create or modify MySQL Wire Protocol driver data sources through the DataDirect ODBC Data Source Administrator for UNIX/Linux.
To configure a data source in the UNIX and Linux environments, you must edit the system information file (by default, odbc.ini) to which the ODBCINI variable points. The default odbc.ini installed by Setup in the installation directory is a template into which you enter your site-specific database connection information. Using a text editor, you modify the default attributes in this file as necessary, based on your system values (for example, your server name and port number). The following is a sample data source entry for the MySQL Wire Protocol driver:
[ODBC Data Sources] MySQL Wire Protocol=DataDirect 5.3 MySQL Wire Protocol [MySQL Wire Protocol] Driver=ODBCHOME/lib/ivmysql23.so Description=DataDirect 5.3 MySQL Wire Protocol AlternateServers= ApplicationUsingThreads=1 ConnectionRetryCount=0 ConnectionRetryDelay=3 Database=<database_name> DefaultLongDataBuffLen=1024 EnableDescribeParam=0 HostName=<MySQL_host> InteractiveClient=0 LicenseNotice=If DataDirect Connect for ODBC is licensed for the MySQL database the following shall apply: You must purchase commercially licensed MySQL database software or a MySQL Enterprise subscription in order to use the DataDirect Connect for ODBC for MySQL Enterprise driver with MySQL software. LoadBalancing=0 LogonID= Password= PortNumber=3306 ReportCodePageConversionErrors=0 TreatBinaryAsChar=0 [ODBC] IANAAppCodePage=4 InstallDir=ODBCHOME Trace=0 TraceDll=ODBCHOME/lib/odbctrac.so TraceFile=odbctrace.out UseCursorLib=0The file must contain an
[ODBC Data Sources]section, specific data source entries, and an[ODBC]section.Consult the "Connection String Attributes" table of each driver chapter for specific connection attribute values to use in creating data sources.
IMPORTANT: The "Connection String Attributes" table of each driver chapter lists both the long and short name of the attribute. When entering attribute names into data source files, you must use the long name of the attribute. The short name is not valid in the odbc.ini file.
The value of the InstallDir keyword must be the path to the installation directory under which the /lib and /messages directories are contained. The installation process automatically writes your installation directory to the default odbc.ini.
For example, if you choose an installation location of /opt/odbc, then the following line is written to the [ODBC] section of the default odbc.ini:
Testing the Connection
The product installation includes an ODBC application called example that can be used to connect to a data source and execute SQL. The application is located in the installation_directory/example directory.
To run the program after setting up a data source in the odbc.ini, enter
exampleand follow the prompts to enter your data source name, user name, and password. If successful, aSQL>prompt appears and you can type in SQL statements such asSELECT * FROMtable. If example is unable to connect, the appropriate error message is returned.