Download SETTING UP CODBC FOR DB2 to OS/390

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
SETTING UP CODBC FOR DB2 to OS/390
UNIX
**These instructions assume that you have the ability to create and bind a package with your user id. If not, a DB2 DBA,
or someone with the same privileges on the database will need to create a package and collection due to OS/390 security
restrictions.
**Create package privileges need to be set on the collection as well.
**If you have access to the console log, search for DSNL004I for the location and port number
** DSNTIJUZ is a job that is run at DB2 install time and is where the code pages are defined that are to be used
From the ‘SETTING UP YOUR UNIX ENVIRONMENT’ document steps 1 – 8
Following are the steps required to set up a Connect ODBC driver on UNIX
**Conventions used in this document**
-All command samples assume the user is executing from within the Korn (ksh) shell.
-The Connect ODBC installation directory will be referred to as ($ODBC_HOME). The default ($ODBC_HOME) directory is
/opt/odbc.
-The steps below assume you have already run the driver installation script appropriate for your UNIX flavor. For assistance with the
installation script see the online documentation, Connect ODBC Installation Guide.
1. Check your permissions
The following items will require that you have the appropriate permissions to modify your environment, read, write and execute
various files. Therefore, it is best if the user you are logged in as has full r/w/x permissions recursively on the entire Connect ODBC
install directory.
2. Determine which shell you are running
You can execute the env command and check your SHELL variable to find out what shell you are using. If your SHELL points to a
ksh, sh or bsh script then you're in a Korn, Borne or equivalent shell. If your SHELL points to a csh script, you're in C shell.
For the purposes of this document, I will be using the ksh shell. If you wish to switch to that shell, type ksh at your prompt. If you
have a ksh shell available to you, it will be invoked and your prompt will change to a $.
3. Run the DataDirect setup script to set variables
DataDirect installs a shell script that will make necessary changes to your shared library path variable. There are 2 scripts (odbc.csh
and odbc.sh) in the ($ODBC_HOME) directory. The one you will execute is based on your shell. For Korn, Borne and equivalent
shells, source odbc.sh. For C shell, source odbc.csh.
example: $ . odbc.sh
After running the setup script, issue the env command to check that your ($ODBC_HOME)/lib directory has been added to your
shared library path. Below is a list of shared library path variable names on supported UNIX flavors.
AIX-------LIBPATH
HP-UX-----SHLIB_PATH
SOLARIS---LD_LIBRARY_PATH
LINUX-----LD_LIBRARY_PATH
4. Set ODBCINI variable
For an application to locate information about the driver and data source you want to use, the ODBCINI environment variable is
required. The variable should point to the exact path from root to the odbc.ini file where your data source will be set up. MERANT
installs a template odbc.ini in the ($ODBC_HOME) directory.
example: $ ODBCINI= /opt/odbc/odbc.ini; export ODBCINI
5. Test loading the driver with ivtestlib
DataDirect ships a utility to verify that the driver and any required client libaries can be loaded into memory. The ivtestlib tool is
located in the main driver installation/bin directory. The syntax to run the tool is "ivtestlib ($ODBC_HOME)/lib/driver name".
example: to load the Connect ODBC v4.1 DB2 driver on Solaris in the default install directory, you would type
$ ivtestlib /opt/odbc/lib/ivdb218.so
If both the driver and client libraries can be loaded successfully, you will see a message like: "Load of ivdb218.so successful."
6. Set up your data source in the odbc.ini
The default odbc.ini is a template into which you enter your site-specific database connection information. Each database has its own
template, so the information you need will depend on which database you want to connect to. Note that the default odbc.ini contains
user name and password parameters for some data sources. If you fill in these parameters, you will still have to pass them when
connecting from your application. For this reason, and for security reasons (text in the odbc.ini file is not encrypted), you should not
store your user name and password in your odbc.ini data source.
Below is an example of setting up an DB2 data source on Solaris:
[ODBC Data Sources]
DB2 Wire Protocol=DataDirect 4.10 DB2 Wire Protocol Driver
[DB2 Wire Protocol] Driver=/opt/odbc/lib/ivdb218.so
Description=DataDirect 4.10 DB2 Wire Protocol Driver
LogonID=uid
Password=pwd
Location= name of the DB2 database
Collection= provided by the DBA
DB2AppCodePage=37
ServerCharSet=37
IpAddress=db2host
TcpPort=50000
Package=db2pkg <7 or less characters>
QueryBlockSize=8
CharSubTypeType=SYSTEM_DEFAULT
ConversationType=SINGLE_BYTE
CloseConversation=DEALLOC
UserBufferSize=32
MaximumClients=35
Trace=0
GrantExecute=1
GrantAuthid=PUBLIC
OEMANSI=1
DecimalDelimiter=PERIOD
DecimalPrecision=15
StringDelimiter=SINGLE_QUOTE
IsolationLevel=CURSOR_STABILITY
ResourceRelease=DEALLOCATION DynamicSections=32
WithHold=0
[ODBC]
Trace=0
TraceFile=odbctrace.out
TraceDll=/usr2/odbc/lib/odbctrac.so
InstallDir=/usr2/odbc
ConversionTableLocation=/usr2/odbc/tables
UseCursorLib=0
7. Run the bind utility
Go to the lib directory where the bind tool is located. Run the following command:
bind18 <datasource name>
You should be prompted for your DB2 user id and password. If the package is bound and created, a message stating that the bind was
successful will display.
8. Test your connection with demoodbc
Once you have set up your environment and data source, you can use the demoodbc application to test your connection. A compiled
version of the application is installed in ($ODBC_HOME)/demo. The syntax to run it is "demoodbc data_source_name -uid
user_name -pwd password".
example: demoodbc My_DataSource -uid my_user_name -pwd my_password
The demoodbc application is coded to do a select from a table named emp. If you have an emp table in your database, the results will
be returned. If you do not have an emp table, you will get the message "The specified table (emp) is not in the database." This message
should be viewed as a successful connection to the database.
9. Test passing SQL with the example program
DataDirect ships a sample application called example, which installs in the ‘example’ directory. When you run it, you’ll be prompted
for the datasource name, your userid and password. Enter SQL against a table on the database.
10. Common Errors
DataDirect][ODBC DB2 Wire Protocol driver][DB2]L30020 DISTRIBUTION PROTOCOL ERROR CAUSED DEALLOC:
REASON ‘1219’ (‘xxxx’ )
Usually means an invalid userid and/or pw have been entered. Also, verify that the collection is correctly entered in the odbc.ini file.
[DataDirect][ODBC DB2 Wire Protocol driver][DB2]N300 TCP Error: Connection refused.
Check the tcp/ip port number. Incorrect port number supplied.
[DataDirect][ODBC DB2 Wire Protocol]Unknown CID ‘1252’ or ‘XXXX’ given for unilib character conversion.
Verify the code page value set on the database. You entered an invalid value.
When running bind18 error 666 occurs
Usually points to a problem in the odbc.ini if:
Action= set wrong or not set
Driver= set wrong
LogonID set to a user that does not exist
Password is incorrect
ConversionTableLocation not set to ODBC_HOME/table directory in [ODBC] section
InstallDir= set wrong or not set in [ODBC] section