Get started developing applications with the IBM Data Server Driver Package

A lightweight deployment solution for IBM database applications

The IBM Data Server Driver Package (also referred to as the ds driver) can be used to provide runtime support for various customer applications that interact with DB2 for Linux®, UNIX®, and Windows®, z/OS®, IBM i®, and Informix® databases through APIs, including ODBC/CLI, .NET, and JDBC. The IBM Data Server Driver Package supports open source and Java™, as well as applications that use ODBC, OLE DB, and .NET provider. Find out about advantages, disadvantages, and examples of a IBM Data Server Driver Package solution compared with other driver solutions, such as the IBM Data Server Runtime Client solution. Get the details on how the IBM Data Server Driver Package is supported across various platforms and languages. Learn how to install and configure the IBM Data Server Driver Package, how to use configuration files, and how to deploy and upgrade this package on Linux, UNIX, and Windows.

Share:

Deepasri Krishnaraja (deepaskr@in.ibm.com), Software Test Specialist, IBM

Photo of Deepasri KrishnarajaDeepasri Krishnaraja works with IBM Common Application Development for the CLI QA team in IBM India Software Labs. She has been working on the DB2 CLI Driver since 2008. She has worked on the automation of the DS Driver for LUW and z/OS for the CLI driver.



Arun Kn Purnaiah (arunkumar.np@in.ibm.com), Development Engineer, IBM

Photo of Arun Kn PurnaiahArun Kn Purnaiah is a Development Engineer for the IBM Data Server CLI Driver team with IBM Software Labs, India. He has been working on the DB2 CLI Driver since 2008. He works on new features for the CLI Driver.



24 March 2011

Also available in Chinese

Introduction

Introduced as part of DB2 Connect™ Version 9.5 Fix Pack 3, the IBM Data Server Driver Package (ds driver) is the best way to get runtime support for applications that need to interact directly with a database without having to actually build the applications with ODBC or CLI APIs. The big advantage of the IBM Data Server Driver Package is its small footprint compared with the IBM Data Server Runtime Client or the IBM Data Server Client. The IBM Data Server Driver Package is designed to be redistributed by Independent Software Vendors (ISVs) and to be used for application distribution in mass deployment scenarios in typically large enterprise database environments.

The IBM Data Server Driver Package provides support for applications developed using the following APIs using application-specific drivers:

  • ODBC, CLI, SQLJ, and JDBC
  • Open source drivers Ruby, Python, PHP, and Perl
  • Windows-platform drivers .NET Provider (.NET) and OLE DB Provider (OLE DB)

By using the IBM Data Server Driver Package, applications can use any of these protocols to perform database operations, without having to rely on the IBM Data Server Runtime Client or the IBM Data Server Client. The IBM Data Server Driver Package can also be used in conjunction with many user-friendly tools and command line utilities, such as CLPPlus.

Figure 1 shows that multiple applications using the application-specific drivers that are shipped as part of the IBM Data Server Driver Package can communicate with various IBM databases.

Figure 1. Applications using IBM Data Server Driver Package
shows applications in Java, C, and .Net using IBM Data Server Driver Package to access the CLI and then various databases such as DB2 for i

Supported platforms and languages

You can use the IBM Data Server Driver Package on the following client platforms:

  • AIX® 64-bit, on pSeries®
  • HP-UX 64-bit, Itanium-based HP Integrity Series
  • Linux 32-bit, x86-32 on AMD and Intel®
  • Linux 64-bit, x86-64 on AMD64 and Intel EM64T
  • Linux 64-bit, POWER® (PowerPC®, iSeries®, pSeries)
  • Linux 64-bit, System z®, System z®, or zSeries®
  • Solaris 64-bit, SPARC on UltraSPARC or SPARC64
  • Solaris 64-bit, x86-64 on Intel 64 or AMD64
  • Windows 32-bit, x86 on Intel or AMD
  • Windows 64-bit, x86 on AMD64 and Intel EM64T

The IBM Data Server Driver Package supports the following languages:

  • Arabic
  • Chinese (Simplified)
  • Chinese (Traditional)
  • Japanese
  • Korean
  • Bulgarian
  • Croatian
  • Czech
  • Danish
  • Dutch
  • English
  • Finnish
  • French
  • German
  • Greek
  • Hebrew
  • Hungarian
  • Italian
  • Norwegian
  • Polish
  • Portuguese (Brazilian)
  • Portuguese
  • Romanian
  • Russian
  • Spanish
  • Slovak
  • Slovenian
  • Swedish

There are separate installation images for each language supported. The IBM Data Server Driver Package can accept the data in any of these languages, and it can send responses in the appropriate language to the user.

The lists describe the platforms and languages supported in DB2 V9.7. See Resources to determine which platforms or languages are supported in subsequent versions of DB2.

Informix support

The IBM Data Server Driver Package supports .NET, Perl, PHP, Python, Ruby, and ODBC application development for Informix databases. .NET is an important interface for developing applications to the Informix database. For more information, see the article Get started with the IBM Data Server CLI Driver for Informix (developerWorks, Dec 2010) in the Resources section.

Understanding the advantages of using the IBM Data Server Driver Package

Following are some of the reasons to use the IBM Data Server Driver Package over another driver. The IBM Data Server Driver Package:

  • Is easier to download and install.
  • Is easier to deploy because of its small footprint.
  • Requires fewer packages to bind to the server, and the packages have not changed since DB2 V8. This is a key factor for DB2 Connect customers.
  • Is easier to upgrade. In order to upgrade the IBM Data Server Runtime Client or the IBM Data Server Client, you need to plan ahead because of the larger sizes and space requirements. Because IBM Data Server Driver Package occupies less space, upgrades are easy.
  • Can be conveniently redistributed by independent software vendors (ISVs).
  • Can be used for application distribution in large-scale deployment scenarios.

Understanding the limitations of the IBM Data Server Driver Package

When evaluating which solution to select for runtime support, you should be aware of the following limitations of the IBM Data Server Driver Package:

  • DB2 Command Line Processor (CLP) functionality is not supported.
  • Cataloging is not supported.
  • CLIENT type authentication is not supported.
  • There is no local database directory. Lightweight Directory Access Protocol (LDAP) cache is not saved to disk.

In order to bind packages, db2bind cannot be used in IBM Data Server Driver Package. To overcome this limitation, jcc.DB2Binder can be used. See Resources for more information about jcc.DB2Binder.


Comparing the IBM Data Server Driver Package and the IBM Data Server Runtime Client

Table 1 highlights some specific differences between the IBM Data Server Driver Package and the IBM Data Server Runtime Client.

Table 1. Comparing the IBM Data Server Driver Package and the IBM Data Server Runtime Client
Comparison criterionIBM Data Server Driver PackageIBM Data Server Runtime Client
SizeSmaller footprint (approximately 130 MB)Larger footprint (approximately 300 MB)
ToolsDB2 Command Line Processor (CLP) not supportedDB2 Command Line Processor (CLP) supported
CLI load APIsNot supportedSupported
Authentication typeCLIENT type authentication not supportedSupports all types of authentication

Learning the history of the IBM Data Server Driver Package

The IBM Data Server Driver Package was first released in DB2 V9.5 Fix Pack 3. The IBM Data Server Driver Package has evolved with subsequent fix pack releases. Some of the major changes include easier installation, the introduction of new tools, and the standardization of installation files. The following sections show the features found in DB2 V9.5 Fix Pack 3 and DB2 V9.7.

DB2 V9.5 Fix Pack 3

Installation and support
  • On Linux and UNIX platforms, the installation process is manual.
  • OLE database support is introduced.
Tools provided
  • The tools db2cli, db2dsdcfgfill, and DRDA trace utility db2drdat are available.
  • The testconn20 tool is provided to test the connection with .NET Provider.
Rebuilding open source drivers
  • The application header files are provided. These header files can be used to rebuild Ruby and PHP drivers.

DB2 v9.7 (up to Fix Pack 3a)

Installation and support
  • On Linux and UNIX platforms, installDSDriver script facilitates the proper installation of the IBM Data Server Driver Package.
  • Support is included for running embedded SQL applications.
Command Line Tool
  • The CLPPLUS tool is provided to dynamically create, edit, and run the SQL statements.
CLI enhancements
  • Starting in DB2 V9.7 Fix Pack 3, the location of configuration files db2cli.ini and db2dsdriver.cfg on the Windows platform is standardized.
  • Starting in DB2 V9.7 Fix Pack 3, the configuration files are shipped as db2cli.ini.sample and db2dsdriver.cfg.sample. These two files are example configuration files, and you can refer these files to create db2cli.ini or db2dsdriver.cfg files manually according to your requirements.
  • Starting in DB2 V9.7 Fix Pack 3, the db2cli tool is enhanced with new options.
Open source enhancements (available from DB2 V9.7 GA)
  • The Python driver is shipped with this release.
  • The drivers Python, PHP, Ruby, and Perl can be rebuilt using application header files. The Perl driver is not shipped with the IBM Data Server Driver Package; it must be downloaded separately.
  • The Ruby driver and Rails adaptor are provided.
  • Two types of PHP drivers are introduced: IBM API and PDO API.
  • Two types of Python drivers are introduced: IBM API and DBI API.
.NET enhancements (available from DB2 V9.7 GA)
  • On Windows 64, support for .NET Provider is included using IBM Database Add-in and Visual Studio.
  • Support for .NET's Entity Framework Provider is included, which is used when developing applications using LINQ.
  • Support for monitoring .NET application through Optim Performance Manager Extended Insight is included.
JDBC and SQLJ enhancements
  • The JDBC and SQLJ support is enhanced in subsequent fix pack releases of the DB2 V9.7. See Resources for more information.
LDAP support
  • LDAP support is provided starting in DB2 V9.7 Fix Pack 2 with the restriction that the LDAP cache is not saved to disk; it is in memory cache only.

Introducing the IBM Data Server Driver Package components

The IBM Data Server Driver Package consists of ODBC/CLI, .NET, OLE DB, Open source, SQLJ, and JDBC driver components. The following sections describe how these components use the configuration files. The tools, utilities, and diagnostic support these components provide are also described.

Configuration files

The IBM Data Server Driver Package uses three different configuration files:

  • db2cli.ini
  • db2dsdriver.cfg
  • DB2JccConfiguration.properties

With the exception of JDBC and SQLJ, these configuration files are used by the drivers available in the IBM Data Server Driver Package. Table 2 shows the configuration files that are applicable to the available drivers.

Table 2. Configuration files used by the IBM Data Server Driver Package
Configuration filesODBC, CLIPHP, Python, Ruby, Perl.NETOLEDBJDBC, SQLJCLPPlus
db2cli.iniYesYesNoYesNoNo
db2dsdriver.cfgYesYesYesYesNoYes
DB2JccConfiguration.propertiesNoNoNoNoYesNo

The open source drivers expose their attributes at the scripting language or framework level so that the db2cli.ini and db2dsdriver.cfg configuration files are transparent to the application developer. The db2dsdriver.cfg file is the default configuration file used by .NET. Consequently, .NET is not affected by settings in the db2cli.ini file. JDBC and SQLJ configuration properties can be set in a resource named DB2JccConfiguration.properties. See Resources to learn how configuration properties can be set in other ways.

Table 3 shows where the configuration files used by the IBM Data Server Driver Package are typically stored.

Table 3. Configuration file locations
PlatformConfiguration file location
Linux<INSTALL-DIR>/cfg/db2cli.ini
<INSTALL-DIR>/cfg/db2dsdriver.cfg
UNIX<INSTALL-DIR>/cfg/db2cli.ini
<INSTALL-DIR>/cfg/db2dsdriver.cfg
Windows 2003, Windows XP®C:\Documents and Settings\All Users\Application Data\IBM\DB2\<COPY_NAME>\cfg\db2cli.ini
C:\Documents and Settings\All Users\Application Data\IBM\DB2\<COPY_NAME>\cfg\db2dsdriver.cfg
Windows Vista®, Windows 7®, Windows 2008®C:\ProgramData\IBM\DB2\<COPY_NAME>\cfg\db2cli.ini
C:\ProgramData\IBM\DB2\<COPY_NAME>\cfg\db2dsdriver.cfg
INSTALL-DIR
Represents the installation path where the IBM Data Server Driver Package is installed. On Linux and UNIX platforms, the installation path is typically the path where the IBM Data Server Driver Package was unzipped, such as /home/db2inst1/dsdriver. On Windows, the installation path is the directory specified during installation.
COPY_NAME
Represents the copy name specified during the IBM Data Server Driver Package installation for the Windows platform only.

A closer look at the db2cli.ini configuration file

The db2cli.ini configuration file is a text-based file that consists of keywords and values. The keywords used can be initialized for a particular data source name (DSN). The driver reads all keywords under a specific DSN before connecting to that data source. This file also has a COMMON section, which contains keywords that the driver reads regardless of the DSN specified in the connection string. Listing 1 offers a sample db2cli.ini file.

Listing 1. db2cli.ini file example
; DSN section here 'DSNSAMPLE' is the DSN name
[DSNSAMPLE]
Database=SAMPLE
Hostname=server1.net1.com
Port=45672

;COMMON section
[COMMON]
AutoCommit=1

A closer look at the db2dsdriver.cfg configuration file

The db2dsdriver.cfg configuration file is an XML file that is based on the db2dsdriver.xsd schema definition file. Listing 2 offers a sample db2dsdriver.cfg file.

Listing 2. db2dsdriver.cfg example
<configuration>
	<dsncollection>
		<dsn alias="alias1" name="name1" host="server1.net1.com" port="50001"/>
	</dsncollection>
	<databases>
		<database name="name1" host="server1.net1.com" port="50001">
		<parameter name="Authentication" value="Server_Encrypt"/>
	</database>
	</databases>
	<parameters>
		<parameter name="GlobalParam" value="Value"/>
	</parameters>
</configuration>

The sample configuration file contains the following sections:

  • A data source name section, which is contained within the <dsncollection> tags
  • A database information section, which is contained within the <databases> tags
  • A global attributes section, which is contained within the <parameters> tags

If the keyword is initialized with a specific value in the connection string and the same keyword is set with a different value in the db2cli.ini or db2dsdriver.cfg file, the value in the connection string takes precedence. The keyword with a different value in the db2cli.ini or db2dsdriver.cfg is ignored.

Utilities

Several user-friendly utilities are shipped with the IBM Data Server Driver Package. Following are these utilities, which are located in the bin folder of the install directory.

db2cli tool
This utility is an interactive tool that can be used to perform the following operations:
db2dsdriver.cfg schema validation
The db2dsdriver.cfg configuration file that the application uses might not be complaint with the existing schema. In such cases, the CLI driver will not read the parameters specified in the db2dsdriver.cfg, which makes it difficult to identify any schema problem in db2dsdriver.cfg. You can easily solve this problem by using the db2cli tool with the validate option specified: db2cli validate. This performs the db2dsdriver.cfg schema validation and, upon finding any schema errors, displays them with specific tag names and line numbers.
Keywords and parameters validation
Applications can specify certain keywords and parameters in the db2cli.ini configuration file under a particular DSN section. During connection, the CLI driver reads those keywords and parameters, and if any keywords or parameters are spelled incorrectly, the driver ignores those misspelled keywords and parameters. You can use the db2cli tool with options to check the validity of the keywords and parameters: db2cli validate -dsn <dsn name> . The db2cli tool provides the list of valid keywords and parameters that the driver reads during connection.

On the other hand, if you provide connection parameters in the database section of the db2dsdriver.cfg file, the validation of those parameters can also be done with the db2cli utility: db2cli validate -database <dbname:server:port> . In this case the matching DSN section need not be present in the db2dsdriver.cfg file.

Note that the db2cli validate command also displays the path from where the configuration files are read: db2cli validate -help

Addition and removal of DSN information
The db2cli utility provides a Windows platform-specific option that enables you to add or remove a DSN in the Microsoft ODBC Data Source Administrator, as shown in Listing 3
Listing 3. Add or remove a DSN
db2cli registerdsn –add <dsnname>
db2cli registerdsn –remove <dsnname>

When the db2cli utility is invoked with this option, the utility reads the DSN specified in either the db2cli.ini or db2dsdriver.cfg file and adds it under the System or User DSN section of the Microsoft ODBC Data Source Administrator section. For more information, invoke the help text by typing: db2cli registerdsn –help .
Execution of interactive CLI scripts
The db2cli utility can be used to quickly prototype and analyze the driver behavior by executing sample test cases. For more information, invoke the help text by typing: db2cli –help

See Resources for db2cli online help.

db2dsdcfgfill utility
When a copy of IBM Data Server Client or IBM Data Server Runtime Client is installed on a server, entries for all catalogued databases are located in the database directory. By invoking the db2dsdcfgfill utility after the IBM Data Server Driver Package has been installed, you can create and populate the db2dsdriver.cfg file automatically using the database entries found in the database directory: db2dsdcfgfill –I <instance-name>

For more information, invoke the help text by typing: db2dsdcfgfill -?.

testconn11 and testconn20
Applications using .NET can quickly check the database connectivity with the testconn utility. testconn11 and testconn20 utilities correspond to .NET Framework Versions 1.1 and 2.0, respectively. For example, database connectivity with .NET Framework 2.0 can be tested by typing the following:
Testconn20 Database=db2db;Server=mymachine:60000;UserID=db2user;Password=xxxxxxxx
db2trc
Use this utility generate a trace if errors are encountered when an application attempts to use the IBM Data Server Driver Package to perform database-related operations. Complete the following steps to perform a trace:
  1. Enter db2trc on -cli -f <trcfilename.dmp>.
  2. Run the application by entering db2trc off.
  3. Generate a CLI trace file with .dmp trace file by entering db2trc fmt -cli <trcfilename.dmp> <trcfilename.cli>
CLPPlus
CLPPlus is a unified command line processing tool that is capable of executing SQL commands and SQL scripts. Following are additional functions available in the CLPPlus tool:
  • Support for generating formatted reports for the executed queries
  • Support for developing SQL scripts and execution of selected utility commands supported by the IBM Data Server Driver.
  • Capability to easily migrate existing scripts from non-IBM data servers to the IBM Data Server Driver Package.
See Resources for more information about the CLPPlus utility.

Diagnostic support

Applications using IBM Data Server Driver Package can diagnose database-related problems by performing a trace. The ODBC, CLI driver, open source drivers, and OLE DB drivers can all use the CLI tracing mechanism. A CLI trace can be enabled with the db2trc utility. A CLI trace can also be enabled by adding keywords, such as Trace and TracePathName, to the db2cli.ini file. For example, these keywords can be specified in the COMMON section of the db2cli.ini file, as shown in Listing 4.

Listing 4. Adding keywords
[COMMON]
Trace=1
TracePathName=<path>

For more information about tracing mechanisms, see Resources.

A JDBC or SQLJ trace can be enabled using configuration properties. See Resources for more information about JDBC and SQLJ tracing mechanisms.


Installing the IBM Data Server Driver Package in Windows environments

After you have edited the configuration files appropriately, you are ready to install the IBM Data Server Driver Package. The IBM Data Server Driver Package on Windows can be installed in any of the following ways:

Prerequisites

  • The IBM Data Server Driver Package must be installed separately.
  • No other DB2 database product can be installed in the same path if the IBM Data Server Driver Package is already installed.
  • Only one copy of any data server client package is recommended. You should uninstall any existing data server client package installations if migrating from another client package.
  • The DB2 setup wizard does not accept non-English characters.

Installing the IBM Data Server Driver Package from a fix pack image (Windows)

Complete the following steps to download and install the IBM Data Server Driver Package from a fix pack image on the Windows platform.

  1. Download the driver package that contains the setup program from the IBM Support Fix Central Web site (see Resources).
  2. Run the setup executable to begin installing the downloaded IBM Data Server Driver Package. Figure 2 shows the resulting welcome screen.
    Figure 2. Welcome screen
    Screen cap: Welcome to the setup wizard
  3. Accept the terms of the license agreement, as shown in Figure 3.
    Figure 3. Software license agreement
    Screen cap: Click the radio button to accept
  4. Select the IBM Data Server Driver Package installation path, as shown in Figure 4.
    Figure 4. Installation path
    Screen cap: Shows selecting the installation path
  5. Provide the IBM Data Server Driver Package COPY_NAME, which should be the location in which the package will be installed. The default COPY_NAME is IBMDBCL1, as shown in Figure 5. However, the driver COPY_NAME can be different than the default name.
    Figure 5. Provide the IBM Data Server Driver Package COPY_NAME
    Screen cap: shows selecting the IBM Data Server Driver Copy Name
  6. Verify the installation settings to make sure all the appropriate paths are specified, as shown in Figure 6.
    Figure 6. Reviewing the installation settings
    Screen cap: shows current settings

After installing the IBM Data Server Driver Package, you can optionally create and populate the configuration file, db2dsdriver.cfg, with database directory information. See Resources for help populating the db2dsdriver.cfg file.

Installing the IBM Data Server Driver Package using the command line options

The setup command can be issued with many options to perform a wide range of operations, as shown in Table 4.

Table 4. Setup command-line options
Command-line optionsWhat the option specifies
n [copy nameCopy name the installation will use
/oInstallation with a generated default copy name will be performed
/u [response file]Full path and file name of the response file
/mShows the progress dialog during the installation
/l [log file]Full path and file name of the log file
/p[install-directory]Changes the installation path of the product. This overrides the installation path that is specified in the response file.
/i languageTwo-letter language code of the language the installation is to use
/?Displays usage information

For example, to install a new copy with a generated default COPY_NAME, use the command setup /o. To install a second copy (though this is not recommended), use the command setup /n <COPY_NAME> .

Installing the IBM Data Server Driver Package from the product DVD (Windows)

  1. Log on to the system with the user account that you want to use to perform the installation.
  2. Optionally shut down any other programs.
  3. Insert the DVD into the drive. The auto-run feature starts the DB2 setup wizard, which determines the system language and starts the setup program for that language.
  4. Run the setup command from the product DVD. There are separate installation images for each language. Run setup.exe with the -i parameter to specify the two-letter language code for the language the installation is to use.

Installing the IBM Data Server Driver Package on Linux and UNIX

Complete the following steps to install the IBM Data Server Driver Package on Linux or UNIX platforms.

  1. Download the driver package that contains the setup program from the IBM Support Fix Central Web site (see Resources).
  2. Uncompress the IBM Data Server driver package archive.
  3. Copy the files onto the target machine.
  4. Enter the installDSDriver command to install the IBM Data Server Driver Package in the Linux or UNIX operating system.

Upgrading the IBM Data Server Driver Package (Windows platform only)

If the IBM Data Server Driver Package has been installed on a Windows server, it can be upgraded in one of the following ways:

  • At the release level
  • At the inter-fix-pack level

Upgrading at the release level (Windows)

Upgrading the IBM Data Server Driver Package from the current release to a new release is equivalent to a new installation. The installation wizard installs the latest version of the IBM Data Server Driver Package at a different location with a new copyname. Complete the following steps to install the upgrade.

  1. Download the latest release of the IBM Data Server Driver Package setup.exe file.
  2. Run the setup.exe to start the installation at the new path. The IBM Data Server Driver Package product is installed at the new location. A new COPY_NAME is created at location C:\Documents and Settings\All Users\Application Data\IBM\DB2\<COPY_NAME>.
  3. Uninstall the previous release of the IBM Data Server Driver Package if it is no longer required.

Upgrading at the inter-fix-pack level (Windows)

On the Windows platform, for an inter-fix-pack-level upgrade, you can install at the same path where the previous fix pack was deployed. In this case, the new installation files override the previous installation files, but the old COPY_NAME is retained. Complete the following steps to install the upgrade.

  1. Download the inter-fix-pack-level IBM Data Server Driver Package setup.exe file.
  2. Run the setup.exe to start the installation. The installer identifies whether a fix pack of the same release is already installed, as shown in Figure 7.
    Figure 7. Warning message
    Warns user that running setup will perform maintenance or perform installation
  3. Click Yes if you want to install in the same location as the COPY_NAME. This is recommended.
  4. Click No and run the setup.exe from the command prompt. Enter setup.exe /n <COPY_NAME> if you want to install in a different path and a new COPY_NAME, which is not recommended. If installing with the current COPY_NAME, the existing configuration files db2cli.ini and db2dsdriver.cfg are retained at the same location. The new binaries are replaced at the existing installed location. The advantage of this is that the applications can run with the new driver version without modifying anything.

Using the IBM Data Server Driver Package

After installing the IBM Data Server Driver Package, you can easily test the database connection using various drivers and utilities. You can also test database connectivity with sample applications.

The examples in this article show how you can use the IBM Data Server Driver Package for database connectivity with different drivers.

Using the IBM Data Server Driver Package with Microsoft applications

Set up the IBM Data Server Driver Package on the Windows platform and follow the instructions in Resources to validate your installation of the IBM Data Server Driver Package for the most frequently used Microsoft interfaces, including ODBC, ADO.NET, and Visual Studio.

Using the db2cli tool

Listing 5 shows database connectivity with the DB2 CLI driver using the db2cli tool.

Listing 5. Using the CLI driver
File : test.txt
opt echo on
opt callerror on
sqlallocenv 1
sqlallocconnect 1 1
SQLDriverConnect 1 0 "DATABASE=sample;PROTOCOL=TCPIP;PORT=56766;
HOSTNAME=server1.net.com;UID=myuser;PWD=mypwd" -3 255 SQL_DRIVER_NOPROMPT
sqltransact 1 1 sql_rollback
killenv 1

The interactive CLI script in Listing 5 can be executed by giving the test case file as input to the db2cli tool, as shown in Listing 6.

Listing 6. Providing the test case file
 INSTALL-DIR\bin\db2cli < test.txt

Using the Ruby tool

Listing 7 shows the database connection example using the Ruby driver.

Listing 7. Using the Ruby driver
require 'ibm_db'    #If on windows, require 'mswin32/ibm_db'
dbalias = 'userid'
begin
#Connect to railsdb via the DSN alias userid in configuration file
conn = IBM_DB.connect(dbalias,'','')
puts "Connection to alias #{dbalias} is successful"
#Close the open connection
IBM_DB.close conn
rescue StandardError => conn_fail_error
raise "Failed to connect to: #{dbalias}. Reason: #{conn_fail_error}"
end

Refer to the README file provided with PHP or Python for more examples.

Using JDBC

Refer to the sample JDBC application link in Resources.


Conclusion

This article offered you the basic information needed to start using the IBM Data Server Driver Package. It also showed you some of the advantages the IBM Data Server Driver Package provides over the IBM Data Server Runtime Client, as well as the installation process, platforms, languages, drivers, and the various components that make up the IBM Data Server Driver Package. Because the IBM Data Server Driver Package is a lightweight deployment solution, you can use this driver package, which has a much smaller footprint than the IBM Data Server Runtime Client. The information in this article enables you to take advantage of the IBM Data Server Driver Package with your own applications.

Resources

Learn

Get products and technologies

Discuss

Comments

developerWorks: Sign in

Required fields are indicated with an asterisk (*).


Need an IBM ID?
Forgot your IBM ID?


Forgot your password?
Change your password

By clicking Submit, you agree to the developerWorks terms of use.

 


The first time you sign into developerWorks, a profile is created for you. Information in your profile (your name, country/region, and company name) is displayed to the public and will accompany any content you post, unless you opt to hide your company name. You may update your IBM account at any time.

All information submitted is secure.

Choose your display name



The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerWorks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

Required fields are indicated with an asterisk (*).

(Must be between 3 – 31 characters.)

By clicking Submit, you agree to the developerWorks terms of use.

 


All information submitted is secure.

Dig deeper into Information management on developerWorks


static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=Information Management
ArticleID=643024
ArticleTitle=Get started developing applications with the IBM Data Server Driver Package
publish-date=03242011