Support for elements of the database application development environment.. Support for elements of the database application development environmentenvironment Supported operating systems
Trang 4Before using this information and the product it supports, be sure to read the general information underNotices.
Edition Notice
ThisdocumentcontainsproprietaryinformationofIBM.Itisprovidedunderalicenseagreementandisprotected
bycopyrightlaw.Theinformationcontainedinthispublicationdoesnotincludeanyproductwarranties,andanystatementsprovidedinthismanualshouldnotbeinterpretedassuch
YoucanorderIBMpublicationsonlineorthroughyourlocalIBMrepresentative
Trang 5Part 1 The DB2 database application
development environment 1
Chapter 1 The DB2 database application development environment 3
Chapter 2 Support for elements of the database application development environment 5
Supportforelementsofthedatabaseapplication developmentenvironment 5
Supportedoperatingsystemsfordatabaseapplication development 7
Supportedoperatingsystemsfordatabase applicationdevelopment 7
InstallationrequirementsforDB2clientsand servers(AIX) 7
InstallationrequirementsforDB2clientsand servers(HP-UX) 9
InstallationrequirementsforDB2clientsand servers(Linux) 10
InstallationrequirementsforDB2clientsand servers(SolarisOperatingSystem) 13
InstallationrequirementsforDB2clientsand servers(Windows) 15
DB2Clientsupportfordatabaseapplication development 17
Supporteddatabaseapplicationprogramming interfaces 18
Supporteddatabaseapplicationprogramming interfaces 18
ADO.NETdevelopmentforDB2databases 19
IntroductiontoDB2CLIandODBC 21
IntroductiontoembeddedSQL 23
SupporteddriversforJDBCandSQLJ 24
IBMOLEDBProviderforDB2 26
PerlDBI 27
IntroductiontoPHPapplicationdevelopmentfor DB2 27
Choosinganapplicationprogramminginterface 28 Supportedprogramminglanguagesandcompilers fordatabaseapplicationdevelopment 33
Supportedprogramminglanguagesand compilersfordatabaseapplicationdevelopment 33
Supported.NETdevelopmentsoftware 33
Supportfordatabaseapplicationdevelopmentin C 34
Supportfordatabaseapplicationdevelopmentin C++ 35
Supportfordatabaseapplicationdevelopmentin COBOL 37
Supportfordatabaseapplicationdevelopmentin Fortran 38
SupportedJavaapplicationdevelopment software 38
Supportfordatabaseapplicationdevelopmentin Perl 39
Supportfordatabaseapplicationdevelopmentin PHP 40
Supportfordatabaseapplicationdevelopmentin REXX 41
Supportedtransactionmanagers 41
Supporteddatabaseapplicationdevelopmenttools 42 Chapter 3 Configuring the database application development environment 45
Configuringthedatabaseapplicationdevelopment environment 45
Configuringtheoperatingsystemfordatabase applicationdevelopment 46
Configuringtheoperatingsystemfordatabase applicationdevelopment 46
SettinguptheUNIXapplicationdevelopment environment 47
UNIXenvironmentvariablesettings 48
SettinguptheWindowsapplicationdevelopment environment 48
ConfiguringaDB2clientfordatabaseapplication development 51
Configuringthedevelopmentenvironmentfor applicationprogramminginterfaces 52
Configuringthedevelopmentenvironmentfor applicationprogramminginterfaces 52
SettinguptheCLIenvironment 53
ConfigurationconsiderationsforXAtransaction managers 54
Part 2 Appendixes 57
Appendix A DB2 Database technical information 59
OverviewoftheDB2technicalinformation 59
Documentationfeedback 59
DB2technicallibraryinhardcopyorPDFformat 60
OrderingprintedDB2books 62
DisplayingSQLstatehelpfromthecommandline processor 63
AccessingdifferentversionsoftheDB2Information Center 64
Displayingtopicsinyourpreferredlanguageinthe DB2InformationCenter 64
UpdatingtheDB2InformationCenterinstalledon yourcomputerorintranetserver 65
DB2tutorials 67
DB2troubleshootinginformation 67
TermsandConditions 68
Trang 6Appendix B Notices 69
Trademarks 71
Index 73
Contacting IBM 75
Trang 7Part 1 The DB2 database application development
environment
Trang 9Chapter 1 The DB2 database application development
For eachoftheseelements,choosingwhichsoftwaretousedependsona variety
of factors:
v what is supported;Forexample:DB2supportsafinite numberofoperatingsystems,and databaseAPIs;and foreachAPI, thereisafinite listofsupportedprogramming
languages
v ease of use;Thereare someintegrateddevelopmentenvironmentsthatmakedevelopingdatabaseapplicationsmucheasier
v the nature of the database application you are developing;
Aweb-based applicationhasparticularneedsthatotherapplicationsdon’thave
v strengths of the particular software.Forexample:static,embeddedSQLmightperform betterthandynamicSQLinsomecircumstances
Trang 11Chapter 2 Support for elements of the database application development environment
environment
Supported operating systems for database application development:
DB2 databaseapplicationdevelopment issupportedonthefollowingoperatingsystems:
v WithLinuxonx86and32-bit Windowsoperatingsystems, only32-bit DB2databaseinstancesare supported.On allotheroperatingsystems,only64-bitdb2;databaseinstancesaresupported
v 32-bitdatabaseapplicationscanberunwitheithera 32-bitor64-bit DB2client,anddevelopedwitheithera 32-bitor64-bit DB2Client
v Thereare differencesforbuildingapplicationsin32-bit and64-bitenvironments
inmostcasesontheseoperatingsystems
DB2 Client support for database application development:
ADB2Clientisrequiredfordatabaseapplicationdevelopment forDB2
Supported database application programming interfaces:
Thefollowingapplication programminginterfacescanbeusedtoaccessa DB2database:
Supported programming languages and compilers for database application development:
Trang 12DB2 databaseapplicationdevelopment issupportedinthefollowinglanguages:
Supported transaction managers for use with database applications:
AnytransactionmanagerthatusestheXAinterface canbe usedto manageDB2distributed transactions
Supported development tools for database application development:
The followingintegrateddevelopment environmentsand developmenttoolscanbeusedtodevelop DB2databaseapplications:
v IBMintegrateddatabaseapplication developmentenvironments– TheDeveloperWorkbench
– RationalApplicationDeveloper
v Databaseapplication plug-insforintegrateddevelopmentenvironments– IBM DB2DevelopmentAdd-InforVisualStudio
– EclipseDB2 Plug-In
v Toolsfor developingSQLStatements– SQLAssist
– SQLBuilder– SQLEditor– Commandlineprocessor
v Databaseapplication monitoringandperformancetuningtools– Event Monitor
– Explaintools– CLI/ODBC/JDBC StaticProfiling
v Toolsfor developingwebapplications– WebSphereStudioApplicationDeveloper– DB2Alphablox
Related concepts:
v “Supporteddatabase applicationdevelopmenttools” onpage42
v “Supporteddatabase applicationprogramminginterfaces”onpage18
v “Supportedtransactionmanagers”onpage41
v Chapter1,“TheDB2databaseapplication developmentenvironment,” onpage3
Related tasks:
v “Configuringthedatabase applicationdevelopmentenvironment”onpage45
Trang 13Related reference:
v “DB2Clientsupport fordatabaseapplicationdevelopment”onpage17
v “Supportedoperatingsystemsfordatabaseapplication development”onpage7
v “Supportedprogramming languagesandcompilersfordatabase applicationdevelopment”onpage33
v WithLinuxonx86andWindows operatingsystemsonx86, only32-bit DB2databaseinstancesare supported.On allotheroperatingsystems,only64-bitDB2databaseinstancesaresupported
v 32-bitdatabaseapplicationscanberunwitheithera 32-bitor64-bit DB2client,anddevelopedwitheithera 32-bitor64-bit DB2Client
v Thestepsforbuildingapplicationsina32-bit environmentaresometimesdifferentfromthestepsforbuildingapplicationsina 64-bitenvironment
Related reference:
v “Supportforelementsofthedatabaseapplicationdevelopment environment”onpage5
v “InstallationrequirementsforDB2clientsand servers(Linux)”onpage10
v “InstallationrequirementsforDB2clientsand servers(SolarisOperatingSystem)”onpage13
v “InstallationrequirementsforDB2clientsand servers(Windows)”onpage15
v “InstallationrequirementsforDB2clientsand servers(AIX)”onpage7
v “InstallationrequirementsforDB2clientsand servers(HP-UX)”onpage9
For themostup-to-dateprerequisiteinformation,seehttp://www.ibm.com/software/data/db2/udb/sysreqs.html
Toinstall aDB2 clientorserverproduct,thefollowingoperatingsystem,hardware,and communicationsprerequisitesmust bemet:
Chapter 2 Support for elements of the database application development environment 7
Trang 14Table 1 AIX installation prerequisites
AIX Version Operating System Hardware
AIXVersion5.2.0 DB2clientisavailableusingthe64-bitAIX
kernel
DB2EnterpriseServerEdition,foreithersingle-partitionorpartitioneddatabaseenvironment,isavailablewiththerequired64-bitAIXkernel
Oneof:
v IBMRISC/6000v
v Usethebosbootcommandtoswitchtothe64-bit kernel
Toswitchtoa 64-bitkernel,yourequirerootauthorityandshouldenterthefollowingcommands:
ln -sf /usr/lib/boot/unix_64 /unix
ln -sf /usr/lib/boot/unix_64 /usr/lib/boot/unix bosboot -a
shutdown -Fr
v DB2Version9requiresthe“IBMC++RuntimeEnvironment ComponentsforAIX”whichincludesxlC.rte 8.0.0.4.ThisisavailablefromtheIBMAIXsupportwebsite
v Oneofthefollowingbrowsersisrequiredtoviewonline helpandtorunFirstSteps(db2fs):
– Mozilla 1.4and up– Firefox 1.0and up– Netscape7.0andup
DB2 product installation on NFS (Network File System):
The installationofDB2productsonNFS(Network FileSystem)isnotrecommended RunningDB2 productsonNFS(forexample,NFSmounting/opt/IBM/db2/V9.1 andthenrunningoffcodethatwasphysicallyinstalledonaremote system)requiresseveralmanualsetupsteps Thereare alsoa numberofpotentialissueswithsettingupNFSforDB2.Theseinclude possibleproblemsthatinvolve:
v Performance(impactedbynetworkperformance)
v Availability(youareallowing asinglepointof failure)
v Licensing(thereisnocheckingdone acrossmachines)
v DiagnosingNFSerrorscanbedifficult
Asmentioned, thesetup forNFSwillrequireseveralmanualactionsincluding:
v Ensuringthatthemountpointpreservetheinstallpath
Trang 15v Permissionmust becontrolled(forexample,writepermissionshouldnotbegiventothemounting machine)
v DB2registrieshavetobe setupmanuallyandmaintainedacrossallmountingmachines
v ThelistinstalledDB2 productsand featurescommand(db2ls)mustbeset upandmaintainedproperlyifyouneedtodetectDB2productsandfeatures
v MorecareisrequiredwhenupdatingyourDB2productenvironment
v Morestepsare requiredwhencleaningupontheexportingmachineandthemountingmachine
For detailedinstructions,lookforthe“SettingUpDB2 onNFSMountedFileSystem” whitepaperwhichwillbe availablesoonafter DB2Version9ismadeavailable
v “Communicationprotocolssupported”inQuick Beginnings for DB2 Clients
For themostup-to-dateprerequisiteinformation,seehttp://www.ibm.com/software/data/db2/udb/sysreqs.html
Toinstall aDB2 clientorserverproduct,thefollowingoperatingsystem,hardware,and communicationsprerequisitesmust bemet:
Table 2 HP-UX installation prerequisites for HP-UX 11iv2
Operating System Hardware
DB2productscanrunonHP-UX11iv2(11.23.0505)forPA-RISC
2.x-based(PA-8x00)andItanium-basedsystemswith:
v
May2005BaseQuality(QPKBASE)bundle
v
May2005ApplicationsQuality(QPAPPS)bundle
andthePHNE_32606patch.(64-bitHP-UXkernelisrequired;server
Kernel configuration considerations:
Asystemrestart isrequiredifyouupdatethekernelconfigurationparameters.Thekernelconfigurationparametersare setin/etc/system.Dependingonthevalues
of yourkernelconfigurationparameters, youmight needtomodifysomeofthembefore youinstall theDB2Version9clientorserverproducts.Ifthekernelconfigurationparametersaremodified,a rebootisnecessarytomakethechanges
Trang 16– Mozilla 1.4and up– Firefox 1.0and up– Netscape7.0andup
DB2 product installation on NFS (Network File System):
The installationofDB2productsonNFS(Network FileSystem)isnotrecommended RunningDB2 productsonNFS(forexample,NFSmounting/opt/IBM/db2/V9.1 andthenrunningoffcodethatwasphysicallyinstalledonaremote system)requiresseveralmanualsetupsteps Thereare alsoa numberofpotentialissueswithsettingupNFSforDB2.Theseinclude possibleproblemsthatinvolve:
v Performance(impactedbynetworkperformance)
v Availability(youareallowing asinglepointof failure)
v Licensing(thereisnocheckingdone acrossmachines)
v DiagnosingNFSerrorscanbedifficult
Asmentioned, thesetup forNFSwillrequireseveralmanualactionsincluding:
v Ensuringthatthemountpointpreservetheinstallpath
v Permissionmust becontrolled(forexample,writepermissionshouldnotbegiventothemounting machine)
v DB2registrieshavetobe setupmanuallyandmaintainedacrossall mountingmachines
v ThelistinstalledDB2 productsand featurescommand(db2ls)mustbeset upandmaintainedproperlyifyouneedtodetectDB2productsandfeatures
v MorecareisrequiredwhenupdatingyourDB2productenvironment
v Morestepsarerequiredwhencleaningupontheexportingmachineandthemountingmachine
For detailedinstructions,lookfor the“SettingUpDB2onNFSMountedFileSystem” whitepaperwhichwillbe availablesoonafter DB2Version9ismadeavailable
Related tasks:
v “Modifyingkernelparameters(HP-UX)”inQuick Beginnings for DB2 Servers
Related reference:
v “Communicationprotocolssupported”inQuick Beginnings for DB2 Clients
v “IBMSoftwareDevelopmentKitforJavalevelsforDB2 products”inQuick Beginnings for DB2 Servers
For themostup-to-dateprerequisiteinformation,seehttp://www.ibm.com/software/data/db2/udb/sysreqs.html
For thelatestinformationonsupportedLinuxdistributions, pointyourbrowsertohttp://www.ibm.com/db2/linux/validate
The supportedoperatingsystemsforLinuxinclude:
v RedHatEnterpriseLinux4 (RHEL4)Update2
Trang 17v SUSELinuxEnterpriseServer9 (SLES9)ServicePack2
Toinstall aDB2 clientorserverproduct,thefollowingdistribution requirements,hardware,andcommunicationsprerequisites mustbemet:
Table 3 Linux prerequisites
Distribution Requirements Hardware
Youshouldupdateyourkernelconfigurationparameters
inpreparationforyourLinuxdistribution.Thedefault
valuesforparticularkernelparametersarenotsufficient
whenrunningaDB2databasesystem
Youmayalsohaveotherproductsorapplicationsthat
requireLinuxsystemresources.Youshouldsetthe
kernelconfigurationparametersbasedontheneedsof
yourLinuxsystemworkingenvironment
Thekernelconfigurationparametersaresetin
/etc/sysctl.conf.SeetheModifyingkernelparameters
(Linux)sectionoftheDB2InformationCenter
Refertoyouroperatingsystemmanualforinformation
onsettingandactivatingtheseparametersusingthe
v (Clientonly)64-bitzSeriesorSystemz9™
boxes
Package requirements (server only):
ThefollowingtableslistthepackagerequirementsforSUSELinuxandRed HatdistributionsforDB2Version9 partitionedservers
v ThepdkshKornShellpackage isrequiredforallDB2systems
v Aremote shellutilityisrequiredforpartitioneddatabasesystems DB2supportsthefollowingremoteshellutilities:
– rsh– ssh
Bydefault,DB2usesrshwhenexecutingcommandsonremoteDB2nodes,forexample,when startinga remoteDB2database partition.TousetheDB2default,thersh-serverpackage mustbe installed(seetablebelow).For acomparisonbetweenrshand ssh,seethe“Securityissueswhen installingDB2”sectionofthe
Administration Guide: Implementation.
Ifyouchoosetousethershremoteshellutility,inetd(orxinetd)must beinstalledand runningaswell.Ifyouchoosetousethessh remoteshellutility,youneedtoset theDB2RSHCMDregistryvariable immediatelyafter theDB2installationiscomplete Ifthisregistryvariableisnotset,rshisused.FormoreinformationontheDB2RSHCMDregistryvariable,seethePerformance Guide
PackagerequirementsforSUSELinux
Package name Description
pdksh KornShell.Thispackageisrequiredforpartitioneddatabase
environments
Chapter 2 Support for elements of the database application development environment 11
Trang 18Package name Description
openssh Thispackagecontainsasetofserverprogramswhichallow
userstoruncommandson(andfrom)remotecomputersviaasecureshell.ThispackageisnotrequiredifyouusethedefaultconfigurationofDB2withrsh
rsh-server Thispackagecontainsasetofserverprogramswhichallow
userstoruncommandsonremotecomputers,loginintoothercomputers,andcopyfilesbetweencomputers(rsh,rexec,rlogin,andrcp).ThispackageisnotrequiredifyouconfigureDB2tousessh
nfs-utils NetworkFileSystemsupportpackage.Itallowsaccesstolocal
filesfromremotecomputers
PackagerequirementsforRedHat
Directory Package name Description
/SystemEnvironment/Shell pdksh KornShell.Thispackageisrequiredfor
partitioneddatabaseenvironments./Applications/Internet openssh Thispackagecontainsasetofclient
programswhichallowuserstoruncommandsonaremotecomputerviaasecureshell.ThispackageisnotrequiredifyouusethedefaultconfigurationofDB2withrsh
/SystemEnvironment/
Daemons
openssh-server Thispackagecontainsasetofserver
programswhichallowuserstoruncommandsfromaremotecomputervia
asecureshell.ThispackageisnotrequiredifyouusethedefaultconfigurationofDB2withrsh
/SystemEnvironment/
Daemons
rsh-server Thispackagecontainsasetofprograms
whichallowuserstoruncommandson
aremotecomputer.Requiredforpartitioneddatabaseenvironments.ThispackageisnotrequiredifyouconfigureDB2tousessh
/SystemEnvironment/
Daemons
nfs-utils NetworkFileSystemsupportpackage
Itallowsaccesstolocalfilesfromremotecomputers
v AnXWindowSystemsoftwarecapableofrendering agraphicaluser interfaceisrequiredifyouwanttousetheDB2SetupwizardtoinstallDB2orif youwant
touseanyDB2graphicaltools.(AvailableonlyonLinuxforx86andLinuxonAMD64/EM64T.)
DB2 product installation on NFS (Network File System):
Trang 19Theinstallation ofDB2productsonNFS(NetworkFile System)isnotrecommended RunningDB2 productsonNFS(forexample,NFSmounting/opt/IBM/db2/V9.1 andthenrunningoffcodethatwasphysicallyinstalledonaremote system)requiresseveralmanual setupsteps Thereare alsoa numberofpotentialissueswithsettingupNFSforDB2.Theseinclude possibleproblemsthatinvolve:
v Performance(impactedbynetworkperformance)
v Availability(youareallowing asinglepointoffailure)
v Licensing(thereisnocheckingdoneacrossmachines)
v DiagnosingNFSerrorscanbedifficult
Asmentioned, thesetup forNFSwillrequireseveralmanualactionsincluding:
v Ensuringthatthemountpointpreservetheinstall path
v Permissionmust becontrolled(forexample,writepermissionshouldnotbegiventothemounting machine)
v DB2registrieshavetobe setupmanuallyandmaintainedacrossallmountingmachines
v ThelistinstalledDB2 productsand featurescommand(db2ls)mustbeset upandmaintainedproperlyifyouneedtodetectDB2productsandfeatures
v MorecareisrequiredwhenupdatingyourDB2productenvironment
v Morestepsare requiredwhencleaningupontheexportingmachineandthemountingmachine
For detailedinstructions,lookforthe“SettingUpDB2 onNFSMountedFileSystem” whitepaperwhichwillbe availablesoonafter DB2Version9ismadeavailable
Related concepts:
v “SecurityissueswheninstallingtheDB2 databasemanager”inAdministration Guide: Implementation
Related tasks:
v “Modifyingkernelparameters(Linux)”inQuick Beginnings for DB2 Servers
v “PreparingtoinstallDB2forLinuxonzSeries”inQuick Beginnings for DB2 Servers
Related reference:
v “Communicationprotocolssupported”inQuick Beginnings for DB2 Clients
v “IBMSoftwareDevelopmentKitforJavalevelsforDB2 products”inQuick Beginnings for DB2 Servers
v “Communicationsvariables”inPerformance Guide
Trang 20Table 4 Solaris Operating System installation prerequisites
Operating System Hardware
DB2clientandserverproductsaresupportedonthefollowing
SolarisOperatingSystemversions:
Kernel configuration considerations:
Asystem restartisrequiredifyouupdatethekernelconfigurationparameters.Thekernelconfigurationparametersare setin/etc/systemand iftheseparametersrequire modificationtoaccommodate theDB2client,a rebootisnecessarytomakethechanges to/etc/systemeffective.Theseparametersmust beset beforeyouinstall aDB2 client
Software considerations:
v (Clientsonly:)IfyouplantouseKerberosAuthentication,yourequireSolarisOperatingSystem9or higherwithIBMNetworkAuthenticationService(NAS)clientv1.4orhigher.TheNASclientcanbedownloadedfromWebsite:
″Recommended&SecurityPatches″ canbe obtainedfromthehttp://sunsolve.sun.comWebsite.From theSunSolveOnlineWebsite, clickonthe
″Patches″menuitemintheleftpanel
The Java2Standard Edition(J2SE) SolarisOperatingSystemPatchClustersandtheSUNWlibCsoftwarearealso requiredand canbe obtainedfromthe
http://sunsolve.sun.comWebsite
For DB2on64-bitFujitsu PRIMEPOWERsystems,yourequirethefollowing:
v Solaris9 KernelUpdatePatch112233-01orlatertogetthefixforpatch912041-01
The FujitsuPRIMEPOWERpatchesfortheSolaris OperatingSystemcanbedownloadedfromFTSI at:http://download.ftsi.fujitsu.com/
DB2 product installation on NFS (Network File System):
The installationofDB2productsonNFS(Network FileSystem)isnotrecommended RunningDB2 productsonNFS(forexample,NFSmounting/opt/IBM/db2/V9.1 andthenrunningoffcodethatwasphysicallyinstalledonaremote system)requiresseveralmanualsetupsteps Thereare alsoa numberofpotentialissueswithsettingupNFSforDB2.Theseinclude possibleproblemsthatinvolve:
Trang 21v Performance(impactedbynetworkperformance)
v Availability(youareallowing asinglepointoffailure)
v Licensing(thereisnocheckingdoneacrossmachines)
v DiagnosingNFSerrorscanbedifficult
Asmentioned, thesetup forNFSwillrequireseveralmanualactionsincluding:
v Ensuringthatthemountpointpreservetheinstall path
v Permissionmust becontrolled(forexample,writepermissionshouldnotbegiventothemounting machine)
v DB2registrieshavetobe setupmanuallyandmaintainedacrossallmountingmachines
v ThelistinstalledDB2 productsand featurescommand(db2ls)mustbeset upandmaintainedproperlyifyouneedtodetectDB2productsandfeatures
v MorecareisrequiredwhenupdatingyourDB2productenvironment
v Morestepsare requiredwhencleaningupontheexportingmachineandthemountingmachine
For detailedinstructions,lookforthe“SettingUpDB2 onNFSMountedFileSystem” whitepaperwhichwillbe availablesoonafter DB2Version9ismadeavailable
Related tasks:
v “Modifyingkernelparameters(SolarisOperatingEnvironment)”inQuick Beginnings for DB2 Servers
Related reference:
v “Communicationprotocolssupported”inQuick Beginnings for DB2 Clients
v “IBMSoftwareDevelopmentKitforJavalevelsforDB2 products”inQuick Beginnings for DB2 Servers
Trang 22Table 5 Windows installation prerequisites
Operating System Service Pack Hardware
WindowsXPProfessional(32-bit)
WindowsXPProfessionalx64
ServicePack2orlater
AllIntelandAMDprocessorscapableofrunningthesupportedWindowsoperatingsystems(32-bitand64-bit)Windows2003StandardEdition
(32-bitand64-bit)Windows2003AdvancedEdition(32-bitand64-bit)
Windows2003DatacenterEdition(32-bitand64-bit)
ServicePack1orlater
Additional client considerations
DB2 productscontinuetobesupportedonWindows98,WindowsME,Windows NT®,and Windows2000untilDB2Universal DatabaseVersion8.1goesoutofservice.Forexistinginstallations andnewinstallations ofDB2 products,upgradingtoa morecurrentoperatingsystemversionofWindows (suchasWindows 2003)isrecommended.Version9clientscannotbeinstalledonWindows98,WindowsME,orWindows NTServer
4 operatingsystems.IfyouwishtocontinuerunningDB2productsonbacklevelreleasesofWindows,yourequirethefollowingmaintenancelevels:
v WindowsNTVersion4 withServicePack6aorlater
v Windows2000withServicePack4 orlater
v InternetExplorer4.01ServicePack2Windows XPServicePack1 isrequiredforrunningDB2applicationsineither ofthefollowingenvironments:
v ApplicationsthathaveCOM+objectsusingODBC;or
v ApplicationsthatuseOLEDBProviderforODBCwithOLEDBresourcepoolingdisabled
Ifyouareunsureaboutwhetheryourapplication environmentqualifies,then itisrecommendedthatyouinstalltheappropriateWindowsservicelevel
For moreinformationaboutthisCOM+issue,seethefollowingMicrosoft®Knowledge Basearticle:
v http://support.microsoft.com/default.aspx?scid=KB;EN-US;306414
Additional software considerations
v MDAC2.8isrequired.TheDB2Setupwizardwillinstall MDAC2.8ifit
isnotalreadyinstalled
Note: Ifaprevious versionofMDAC(forexample,2.7)isalreadyinstalled,DB2installwillupgradeMDACto2.8.For atypicalinstall,MDAC2.8isinstalled.Fora compactinstall,MDAC2.8isnotinstalled.For acustominstall, MDAC2.8isinstalledbutonly
ifyouhavenotdeselected thedefaultwhichistoinstallit.IfyoudeselectMDACaspartofa custominstall,itwillnotbe installed
Trang 23v If youplantouseLDAP(Lightweight DirectoryAccessProtocol),youshoulduseeitheraMicrosoft LDAPclientortheIBMTivoli®DirectoryServer v6client(alsoknown astheIBM LDAPclientwhichisincludedwith DB2).PriortoinstallationoftheMicrosoftActiveDirectory,youwillneedtoextendyourdirectory schemausingthedb2schexutility,whichcanbe foundontheinstallationmedia.
The MicrosoftLDAPclientisincludedwith theoperatingsystem forWindows XP,andWindowsServer 2003
v If youplantousetheTivoliStorageManagerfacilitiesforthebackupand restorationofyourdatabases,youneedtheTivoliStorageManagerClient Version4.2.0orlater
– For Windows64-bitoperatingsystems, yourequire theTSMclientAPIVersion5.1
v If youhavetheIBMAntivirusprograminstalledonyour operatingsystem,it mustbe disabledoruninstalledtocompletea DB2installation
v TCP/IPsupportmust beenabled toviewonline help
v Oneofthefollowingbrowsersisrequiredtoview onlinehelp,runtheDB2 installlaunchpad(setup.exe),andtorunFirstSteps(db2fs):
– Internet Explorer5.5and up– Mozilla 1.4and up
– Firefox 1.0and up– Netscape7.0andup
v “Communicationprotocolssupported”inQuick Beginnings for DB2 Clients
Thereare twoDB2clients:theDB2Client;and theDB2Runtime Client.Ofthetwo, onlytheDB2Clientissuitablefordatabaseapplicationdevelopment
TheDB2 Clientincludesthefollowing:
v Precompilers for C/C++, COBOL, and Fortran,(providingthelanguageissupportedforthatplatform)
v Embedded SQL application support,includingprogramminglibraries,includefilesandcodesamples
v ODBC and DB2 Call Level Interface (DB2 CLI) application support,includingprogramminglibraries,includefiles,andcode samplesfor developing
applicationswhichare easilyportedtoODBCandcompiledwith anODBCSDK.AnODBC SDKisavailable fromMicrosoftforWindows operatingsystems,andfromvariousothervendorsformanyof theothersupportedplatforms.OnWindowsoperatingsystems, theODBCandCLIdriverisinstalled
Chapter 2 Support for elements of the database application development environment 17
Trang 24bydefaultwith theDB2 Client,supportingapplicationsdevelopedwiththeMicrosoftODBCSoftwareDeveloper’sKit.Forall otherplatforms,theODBCandCLIdrivercanoptionallybe installedwith theDB2Client,supportingapplicationsthatcanbe developedwith anODBCSDKforthatplatform,ifoneexists.
v The IBM DB2 Driver for JDBC and SQLJ,whichincludes:
– JDBC support,fordevelopingJavaapplicationswithdynamicSQL– SQLJsupport,fordevelopingJavaapplicationswith staticSQL
v An SDK for JavaisshippedwithDB2 clientsforallsupportedoperatingsystems
v ActiveX Data Objects (ADO) and Object Linking and Embedding (OLE) automation routines (UDFs and Stored Procedures)onWindows operatingsystems,includingcodesamplesimplementedinMicrosoftVisualBasicandMicrosoftVisualC++.Also, codesampleswithRemoteDataObjects(RDO)implementedinMicrosoftVisualBasic
v Object Linking and Embedding Database (OLE DB) table functionsonWindowsoperatingsystems
v C# and Visual Basic NET applications and CLR NET routinesonWindowsoperatingsystems
v DB2 Developer Workbenchisan Eclipse-basedtoolthatreplacestheDevelopmentCenterfromDB2Universal Database™(DB2UDB)forLinux,UNIX®,andWindowsVersion8.DeveloperWorkbenchisacomprehensivedevelopmentenvironmentforcreating,editing,debugging,deploying, andtestingDB2stored proceduresanduser-definedfunctions.YoucanalsouseDeveloperWorkbenchtodevelop SQLJapplications,andcreate,edit,andrunSQLstatementsandXMLqueries
v Interactive SQLthroughtheCommandEditororCommandLine Processor(CLP)toprototype SQLstatementsortoperformadhocqueries againstthedatabase
v A set of documented APIstoenableotherapplication developmenttoolstoimplementprecompilersupport forDB2directlywithin theirproducts.Forexample,IBM COBOLonAIXusesthisinterface
Youcanuseseveraldifferentprogramming interfacestomanage oraccessDB2databases Youcan:
v UseDB2APIsto performadministrativefunctionssuchasbackingupandrestoringdatabases
v EmbedstaticanddynamicSQLstatementsinyourapplications
Trang 25v CodeDB2CallLevelInterface(DB2CLI)functioncalls inyourapplicationstoinvokedynamicSQLstatements.
v DevelopJavaapplicationsandappletsthatcalltheJavaDatabaseConnectivityapplicationprogramminginterface (JDBCAPI)
v DevelopMicrosoftVisualBasicand VisualC++applicationsthatconformtoDataAccessObject(DAO)and RemoteData Object(RDO)specifications,andActiveXDataObject(ADO)applicationsthatusetheOLEDBBridge
v DevelopADO.NETapplicationsusingDB2.NET DataProvider,OLEDB.NETDataProviderorODBC.NET DataProvider
v DevelopapplicationsusingIBMorthird-party toolssuchasNet.Data®,Excel,Perl,andOpenDatabaseConnectivity (ODBC)end-usertoolssuchasLotus®Approach®,anditsprogramminglanguage,LotusScript
Related concepts:
v “OLEDB.NETData Provider”onpage21
v “ADO.NETdevelopmentforDB2databases”onpage19
v “DB2.NET DataProvider” onpage19
v “ODBC.NET DataProvider”onpage20
v “IBMOLEDBProviderforDB2”onpage26
v “IntroductiontoDB2 CLIand ODBC”onpage21
v “Introductiontoembedded SQL”onpage23
v “Supporteddrivers forJDBCandSQLJ”onpage24
v “PerlDBI”onpage27
v “IntroductiontoPHPapplicationdevelopment forDB2”onpage27
Related reference:
v “Supportforelementsofthedatabaseapplicationdevelopment environment”onpage5
TheDB2 NETData Providerisanextensionof theADO.NETinterface thatallows.NET applicationstoaccessa DB2databasethrough asecureconnection,executecommands,andretrieveresult sets
ReferencedocumentationisincludedwiththeDB2.NET DataProvider,presentingdetailedinformationaboutalltheDB2.NETData Providerobjectsandtheirmembers.DuringtheDB2installationprocess,this documentationisregisteredwith MicrosoftVisualStudio.NET.Toview theDB2 NETDataProviderdocumentationfromMicrosoftVisualStudio.NET,selecttheHelpmenuoption,and Contents.Once thehelp vieweropens,filterbyIBM DB2 NET Data Provider Help.
TheDB2 NETData Providerextends DB2supportfortheADO.NET interface.TheDB2 NETData Providerdelivershigh-performing,secureaccesstoDB2 data.TheDB2 NETData Providerallows your.NETapplicationstoaccessthefollowingdatabase managementsystems:
v DB2Databasefor Linux,UNIX,andWindows,Version9
Chapter 2 Support for elements of the database application development environment 19
Trang 26v DB2UniversalDatabaseVersion8forWindows,UNIX,andLinux-basedcomputers
v DB2UniversalDatabaseVersion6(orlater)forOS/390®and z/OS®,throughDB2Connect™
v DB2UniversalDatabaseVersion5,Release1(orlater)forAS/400® andiSeries,throughDB2Connect
v DB2UniversalDatabaseVersion7.3(orlater)forVSE&VM,through DB2Connect
Todevelop andrunapplicationsthatuseDB2.NET DataProvideryouneed the.NET Framework,Version2.0or1.1
InadditiontotheDB2.NET DataProvider,theIBMDatabaseDevelopmentAdd-Inenablesyoutoquickly andeasilydevelop.NET applicationsforDB2databasesinVisualStudio2005.YoucanalsousetheAdd-Intocreatedatabaseobjectssuchasindexesandtables,anddevelop server-sideobjects,suchasstoredproceduresand user-definedfunctions
The ODBC.NETDataProvidermakesODBCcallstoa DB2datasourceusingtheDB2 CLIDriver.Therefore,theconnectionstringkeywordssupportedbytheODBC NETDataProviderare thesame asthose supportedbytheDB2CLIdriver.Also, theODBC NETDataProviderhasthesamerestrictionsastheDB2CLIdriver.Thereareadditionalrestrictions fortheODBC.NET DataProvider,whichare identifiedinthetopic:ODBC.NETData Providerrestrictions
InordertousetheODBC.NETData Provider,youmusthavethe.NETFrameworkVersion1.1orVersion2.0installed.ForDB2 UniversalDatabaseforAS/400and iSeries,thefollowingfixisrequiredontheserver:APARII13348.The followingare thesupportedconnectionkeywordsfortheODBC.NETDataProvider:
Table 6.ConnectionStringkeywords for the ODBC NET Data Provider
catalogedinthedatabasedirectory
totheDB2server
usedtoconnecttotheDB2server
The followingisanexampleofcreating anOdbcConnectiontoconnecttotheSAMPLEdatabase:
[Visual Basic NET]
Dim con As New OdbcConnection("DSN=sample;UID=userid;PWD=password;")con.Open()
[C#]
OdbcConnection con = new OdbcConnection("DSN=sample;UID=userid;PWD=password;");con.Open()
Trang 27OLE DB NET Data Provider
TheOLEDB.NET DataProviderusestheIBMDB2OLEDBDriver,whichisreferredtoina ConnectionStringobjectasIBMDADB2.TheconnectionstringkeywordssupportedbytheOLEDB.NETData Providerare thesame asthosesupportedbytheIBM OLEDBProviderforDB2.Also,theOLEDB.NET DataProviderhasthesamerestrictionsastheIBMDB2OLEDBProvider.Thereareadditionalrestrictions fortheOLEDB.NET DataProvider,whichareidentifiedinthetopic:OLEDB.NETData Providerrestrictions
InordertousetheOLE DB.NET DataProvider,youmust havethe.NETFrameworkVersion1.1orVersion2.0installed
For DB2UniversalDatabaseforAS/400andiSeries,thefollowingfixisrequired
ontheserver:APARii13348
Thefollowingare allthesupportedconnectionkeywordsfortheOLEDB.NETData Provider:
Table 7.ConnectionStringkeywords for the OLE DB NET Data Provider
ProviderforDB2(required)DSN orDataSource databasealias TheDB2databasealiasas
catalogedinthedatabasedirectory
totheDB2server
usedtoconnecttotheDB2server
Thefollowingisanexampleofcreating anOleDbConnectiontoconnecttotheSAMPLEdatabase:
[Visual Basic NET]
Dim con As New OleDbConnection("Provider=IBMDADB2;" + "Data Source=sample;UID=userid;PWD=password;")con.Open()
DB2 CallLevel Interface(DB2CLI)isIBM’scallableSQLinterface totheDB2familyofdatabase servers.Itisa ’C’and’C++’applicationprogramming interfaceforrelationaldatabaseaccessthatusesfunctioncallstopass dynamicSQL
statementsasfunction arguments.ItisanalternativetoembeddeddynamicSQL,but unlikeembeddedSQL,DB2 CLIdoesnotrequirehostvariablesora
precompiler
DB2 CLIisbasedontheMicrosoft**OpenDatabaseConnectivity**(ODBC)specification,and theInternationalStandardfor SQL/CLI.Thesespecificationswere chosenasthebasisfortheDB2CallLevelInterfaceinanefforttofollow
Chapter 2 Support for elements of the database application development environment 21
Trang 28industrystandardsand toprovideashorterlearningcurveforthose applicationprogrammers alreadyfamiliar witheitherofthese databaseinterfaces.Inaddition,someDB2 specificextensionshavebeen addedtohelptheapplicationprogrammerspecificallyexploitDB2features.
The DB2CLIdriveralso actsasanODBCdriverwhenloaded byanODBCdrivermanager.ItconformstoODBC 3.51
DB2 CLI Background information:
TounderstandDB2CLIoranycallable SQLinterface,itishelpfultounderstandwhatitisbasedon,andtocompare itwithexistinginterfaces
The X/OpenCompanyandtheSQLAccessGroupjointly developeda specificationfor acallableSQLinterface referredtoastheX/Open Call Level Interface.Thegoal ofthis interfaceistoincreasetheportabilityofapplicationsbyenabling themtobecomeindependentofanyonedatabasevendor’sprogramming interface.MostoftheX/OpenCallLevelInterfacespecificationhasbeenacceptedaspartoftheISOCallLevel InterfaceInternationalStandard (ISO/IEC9075-3:1995SQL/CLI)
Microsoft developedacallableSQLinterface calledOpenDatabaseConnectivity(ODBC) forMicrosoftoperatingsystemsbased onapreliminarydraftofX/OpenCLI
The ODBCspecificationalsoincludesanoperatingenvironmentwheredatabasespecific ODBCDriversaredynamicallyloaded atruntimebyadrivermanagerbased onthedatasource(database name)providedontheconnectrequest.Theapplication islinkeddirectlytoa singledrivermanagerlibraryratherthantoeachDBMS’s library.Thedrivermanager mediatestheapplication’sfunctioncalls atruntimeandensures theyaredirectedtotheappropriateDBMSspecificODBCdriver.SincetheODBCdrivermanageronlyknowsabouttheODBC-specificfunctions,DBMS-specific functionscannotbeaccessedinan ODBCenvironment
DBMS-specific dynamicSQLstatementsaresupportedviaamechanismcalledanescapeclause
ODBC isnotlimitedtoMicrosoft operatingsystems;otherimplementationsareavailable onvariousplatforms
The DB2CLIload librarycanbeloaded asanODBCdriverbyan ODBCdrivermanager.For ODBCapplicationdevelopment,youmustobtainanODBCSoftwareDevelopmentKit.For theWindows platform,theODBCSDKisavailable aspart oftheMicrosoft DataAccessComponents(MDAC)SDK,available fordownloadfromhttp://www.microsoft.com/data/ Fornon-Windowsplatforms,theODBCSDKisprovided byothervendors.WhendevelopingODBCapplicationsthatmayconnect
toDB2 servers,usetheCallLevelInterfaceGuideandReference, Volume1andtheCallLevelInterfaceGuideand Reference,Volume2 (forinformationonDB2specific extensionsanddiagnosticinformation),inconjunctionwith theODBCProgrammer’sReferenceandSDKGuideavailable fromMicrosoft
Applicationswritten directlytoDB2CLIlinkdirectlyto theDB2CLIloadlibrary.DB2 CLIincludessupportfor manyODBCand ISOSQL/CLIfunctions,aswell asDB2 specificfunctions
The followingDB2 featuresare availabletobothODBCandDB2 CLIapplications:
v doublebyte(graphic) datatypes
Trang 29v storedprocedures
v DistributedUnitofWork(DUOW),twophasecommit
v compoundSQL
v userdefinedtypes(UDT)
v userdefinedfunctions(UDF)
Youcandevelopembedded SQLapplicationsforDB2inthefollowinghostprogramming languages:C,C++,COBOL, FORTRAN,andREXX
Note: SupportforembeddedSQLinFORTRANand REXXhasbeendeprecatedandwillremainat theDB2 UniversalDatabase,Version5.2level
Building embeddedSQLapplicationsinvolvestwoprerequisitestepspriortoapplication compilationandlinking
v Preparingthesourcefilescontainingembedded SQLstatementsusingtheDB2precompiler
ThePREP(PRECOMPILE)commandisusedtoinvoketheDB2 precompiler,whichreadsyour sourcecode,parsesandconvertstheembedded SQLstatementstoDB2run-timeservicesAPIcalls,and finallywritestheoutputtoa newmodifiedsourcefile.TheprecompilerproducesaccessplansfortheSQLstatements,whicharestoredtogetherasa packagewithin thedatabase
v Bindingthestatementsintheapplicationtothetargetdatabase
Bindingisdonebydefaultduringprecompilation(thePREPcommand).Ifbindingistobe deferred(forexample,runningtheBINDcommandlater),thentheBINDFILEoptionneedstobespecified atPREPtimein orderforabind fileto
begenerated
Once youhaveprecompiledandboundyour embeddedSQLapplication, itisreadytobe compiledandlinkedusingthehostlanguage-specificdevelopmenttools
Toaidinthedevelopment ofembeddedSQLapplications,youcanrefertotheembedded SQLtemplateinC Examplesofworkingembedded SQLsampleapplicationscanalsobe foundinthe%DB2PATH%\SQLLIB\samplesdirectory
Note: %DB2PATH%referstotheDB2installationdirectory
Static and dynamic SQL:
SQLstatementscanbe executedinoneoftwoways:staticallyordynamically
Chapter 2 Support for elements of the database application development environment 23
Trang 30Statically executed SQL statements
For staticallyexecutedSQLstatements,thesyntax isfullyknownatprecompiletime.Thestructure ofanSQLstatementmustbe completelyspecifiedfor astatementtobeconsideredstatic.Forexample,thenamesforthecolumns andtablesreferenced inastatementmust befullyknown
at precompiletime Theonlyinformationthatcanbespecified atruntimeare valuesforanyhostvariablesreferencedbythestatement.However,hostvariable information,suchasdatatypes, muststillbe precompiled.Youprecompile, bind,andcompilestaticallyexecutedSQLstatementsbefore yourunyourapplication.StaticSQLisbestusedondatabaseswhosestatisticsdonotchangeagreat deal
Dynamically executed SQL statements
DynamicallyexecutedSQLstatementsare builtand executedbyanapplication atrun-time.An interactiveapplicationthatpromptstheenduser forkeypartsofan SQLstatement,suchasthenamesofthetablesandcolumns tobesearched,isagoodexampleofa situationsuitedfor
v “PRECOMPILEcommand”inCommand Reference
According totheJDBCspecification,therearefour typesofJDBC driverarchitectures:
Type 1
DriversthatimplementtheJDBCAPIasa mappingtoanotherdataaccessAPI,suchasOpenDatabaseConnectivity(ODBC).Driversofthistype aregenerallydependentona nativelibrary,whichlimitstheirportability.TheDB2databasesystem doesnotsupport atype1 driver
Type 2
Driversthatarewritten partlyintheJava programminglanguageandpartlyinnativecode.Thedrivers usea nativeclientlibraryspecific tothedatasourcetowhichtheyconnect.Becauseofthenativecode,theirportabilityislimited
Type 3
DriversthatuseapureJavaclientand communicatewith aserverusingadatabase-independent protocol.Theserverthencommunicatestheclient’srequeststothedatasource.TheDB2databasesystem doesnotsupporta type
3 driver
Type 4
DriversthatarepureJava andimplementthenetworkprotocolfora specificdatasource.Theclientconnectsdirectlytothedatasource
Trang 31DB2 Version9.1supportsadriverthatcombinestype2 andtype4 JDBCimplementations.DB2Version9.1alsosupportsa.type2 driver,althoughthissupport isdeprecated TheDB2Version9.1type 2drivercontinuestousetheDB2CLIinterfaceto communicatewithDB2 databaseservers.ThedriversthataresupportedinDB2Version9.1are:
DB2 JDBC Type 2 Driver for Linux, UNIX and Windows (DB2 JDBC type 2 driver) (deprecated):
TheDB2 JDBCtype2 driverletsJava applicationsmakecallstoDB2throughJDBC.Calls totheDB2 JDBCtype2 driveraretranslatedtoJava nativemethods.TheJava applicationsthatusethisdrivermust runona DB2client,throughwhichJDBC requestsflowtotheDB2 server.DB2ConnectVersion9.1mustbe installedbefore theDB2JDBCapplicationdrivercanbe usedtoaccessDB2UDB foriSeriesdatasources ordatasourcesintheDB2forOS/390orz/OSenvironments
TheDB2 JDBCtype2 driversupportsthese JDBCandSQLJfunctions:
v MostofthemethodsthataredescribedintheJDBC1.2specification,andsome
ofthemethodsthataredescribedin theJDBC 2.0specification.SeeComparison
ofdriversupportforJDBCAPIs
v SQLJstatementsthatperform equivalentfunctionstoall JDBCmethods
IBM DB2 Driver for JDBC and SQLJ (type 2 and type 4):
TheIBM DB2DriverforJDBC andSQLJisa singledriverthatincludesJDBCtype
2 andJDBC type4behavior,aswell asSQLJsupport.WhenanapplicationloadstheIBMDB2 DriverforJDBCand SQLJ,a singledriverinstanceisloadedfortype
2 andtype 4implementations.Theapplicationcanmaketype 2andtype 4connectionsusingthissingledriverinstance.Thetype 2andtype 4connectionscanbe madeconcurrently.IBMDB2Driver forJDBCandSQLJtype 2driverbehaviorisreferredtoasIBM DB2 Driver for JDBC and SQLJ type 2 connectivity.
IBM DB2DriverforJDBC andSQLJtype4 driverbehaviorisreferredto asIBM DB2 Driver for JDBC and SQLJ type 4 connectivity.
TheIBM DB2DriverforJDBC andSQLJsupportsthese JDBCandSQLJfunctions:
v Allofthemethodsthatare describedintheJDBC3.0specifications.SeeComparisonofdriversupportforJDBCAPIs
v SQLJstatementsthatperform equivalentfunctionstomostJDBCmethods
v Connectionsthatareenabled forconnectionpooling.WebSphere®ApplicationServeroranotherapplication serverdoestheconnectionpooling
v Javauser-definedfunctionsandstoredprocedures(IBM DB2DriverforJDBCandSQLJtype2connectivity only)
v GlobaltransactionsthatrununderWebSphereApplicationServerVersion5.0andabove
v Supportfordistributed transactionmanagement.Thissupportimplements theJava2Platform,EnterpriseEdition(J2EE)Java TransactionService(JTS)andJavaTransactionAPI(JTA)specifications,whichconformtotheX/Openstandardfordistributedtransactions(Distributed Transaction Processing: The XA Specification,
availablefromhttp://www.opengroup.org)
Chapter 2 Support for elements of the database application development environment 25
Trang 32Related concepts:
v “HowJDBC applicationsconnecttoa datasource”inDeveloping Java Applications
v “SecurityundertheIBMDB2Driver forJDBCand SQLJ”inDeveloping Java Applications
Related reference:
v “DriversupportforJDBCAPIs”inDeveloping Java Applications
v “JDBCdifferencesbetweentheIBMDB2 DriverforJDBCand SQLJand otherDB2JDBCdrivers”inDeveloping Java Applications
v “SQLJdifferencesbetweentheIBM DB2DriverforJDBC andSQLJandotherDB2JDBCdrivers”inDeveloping Java Applications
Microsoft OLEDBisa setofOLE/COMinterfacesthatprovides applicationswithuniform accesstodatastored indiverseinformationsources.TheOLEDB
architecture definesOLEDBconsumersandOLEDBproviders.An OLEDBconsumer isanysystemorapplication thatusesOLEDBinterfaces;an OLEDBproviderisacomponentthatexposesOLEDBinterfaces
The IBMOLEDBProviderfor DB2allowsDB2toactasaresourcemanagerfortheOLEDBprovider.ThissupportgivesOLEDB-basedapplicationstheabilitytoextractorqueryDB2datausingtheOLEinterface.TheIBMOLEDBProviderforDB2,whoseprovidernameisIBMDADB2,enablesOLEDBconsumerstoaccessdataona DB2databaseserver.IfDB2Connectisinstalled,theseOLEDBconsumerscanalsoaccessdataonahostDBMSsuchasDB2 forMVS™,DB2forVM/VSE,orSQL/400®
The IBMOLEDBProviderfor DB2offersthefollowingfeatures:
v Supportlevel0of theOLEDBproviderspecification,includingsomeadditionallevel1 interfaces
v Afreethreaded providerimplementation,whichenablestheapplicationtocreatecomponentsinonethreadandusethosecomponentsinanyotherthread
v AnErrorLookupServicethatreturnsDB2errormessages
NotethattheIBMOLEDBProviderresidesontheclient andisdifferentfromtheOLEDBtablefunctions,whicharealsosupportedbyDB2databasesystems.SubsequentsectionsofthisdocumentdescribethespecificimplementationoftheIBM OLEDBProviderforDB2.For moreinformationontheMicrosoftOLEDB2.0specification,refertotheMicrosoftOLEDB2.0Programmer’sReferenceandDataAccessSDK,available fromMicrosoftPress
Trang 33Toinstall theIBMOLEDBProviderforDB2,youmustfirst berunningononeofthesupportedoperatingsystemslisted above.Youalso needtoinstalltheDB2Client.ThisclientincludesMicrosoftDataAccessComponents(MDAC).
Related reference:
v “IBMOLEDBProvidersupportforOLEDBcomponentsandinterfaces” in
Developing ADO.NET and OLE DB Applications
DB2 supportsthePerlDatabaseInterface(DBI)specificationfordataaccessthrough theDBD::DB2driver.TheDB2Perl DBIwebsiteislocatedat:
http://www.ibm.com/software/data/db2/perl/
and containsthelatestDBD::DB2driver,and relatedinformation
Perl isaninterpretedlanguageandthePerlDBIModuleusesdynamicSQL.ThesepropertiesmakePerl anideallanguageforquickly creatingandrevisingDB2applications.ThePerlDBIModuleusesaninterface thatisquitesimilartotheCLIand JDBCinterfaces,whichmakesiteasytoportPerl applicationstoCLIandJDBC,or toportCLIand JDBCapplicationstoPerl
Related concepts:
v “ProgrammingConsiderations forPerl”inDeveloping Perl and PHP Applications
PHP: HypertextPreprocessor(PHP)isaninterpretedprogramminglanguageprimarilyintended forthedevelopment ofWebapplications.Thefirst versionofPHPwascreatedbyRasmusLerdorfand contributedunderanopensourcelicense
in1995.PHPwas initiallyaverysimple HTMLtemplatingengine,but overtimethedevelopersofPHPaddeddatabase accessfunctionality,rewrotetheinterpreter,introducedobject-orientedsupport,and improvedperformance.Today,PHPhasbecomea popularlanguageforWebapplication developmentbecauseofitsfocus
onpracticalsolutionsand supportforthemostcommonlyrequiredfunctionalityinWebapplications
For theeasiestinstall andconfigurationexperienceonLinux,UNIX,orWindowsoperatingsystems, youcandownloadandinstall ZendCoreforIBMfor useinproductionsystems.Paidsupport forZendCoreforIBM isavailable fromZend
On Windows,precompiledbinaryversionsofPHPareavailablefordownloadfromhttp://php.net/ MostLinuxdistributionsincludea precompiledversionofPHP OnUNIXoperatingsystemsthatdonotincludea precompiledversionofPHP, youcancompileyourown versionofPHP
PHPisa modularlanguagethatenablesyoutocustomizetheavailablefunctionalitythrough theuseofextensions.Theseextensionscansimplifytaskssuchasreading,writing,and manipulatingXML,creating SOAPclientsandservers,and encryptingcommunicationsbetweenserverand browser.ThemostpopularextensionsforPHP,however,providereadand writeaccesstodatabases
sothatyoucaneasilycreatea dynamicdatabase-drivenWebsite IBMsupportsaccesstoDB2databasesfromPHPapplicationsthroughtwoextensionsofferingdistinct setsof features:
v ibm_db2isanextensionwritten,maintained,and supportedbyIBMforaccess
toDB2databases.Theibm_db2extension offersaproceduralapplication
Chapter 2 Support for elements of the database application development environment 27
Trang 34programminginterface(API)that,inadditiontothenormalcreate,read,update,andwritedatabaseoperations,alsooffers extensiveaccesstothedatabasemetadata.Youcancompiletheibm_db2extension witheitherPHP4 orPHP5.
v PDO_ODBCisa driverforthePHPDataObjects(PDO)extensionthatoffersaccesstoDB2 databasesthrough thestandardobject-orienteddatabaseinterfaceintroducedinPHP5.1.Despite itsname, youcancompilethePDO_ODBCextensiondirectlyagainsttheDB2librariestoavoidthecommunicationsoverheadandpotentialinterferenceof anODBCdrivermanager
Athirdextension,UnifiedODBC,hashistoricallyofferedaccesstoDB2databasesystems Itisnotrecommended thatyouwritenewapplicationswiththisextension becauseibm_db2andPDO_ODBCbothoffersignificantperformanceand stabilitybenefitsoverUnifiedODBC.Theibm_db2extensionAPImakesporting anapplicationthatwas previouslywritten forUnifiedODBCalmost aseasy asgloballychangingtheodbc_ functionnametodb2_throughoutthesourcecode ofyourapplication
Which applicationprogramming interface(API)youchoosetousewithyour DB2database applicationshasalargeimpactonthedevelopmentoftheapplication
Tochoose anAPItoaccessaDB2database,do thefollowing:
1. EliminateAPIsthatdon’tsupport thefunctionalityyourequire
v ApplicationenvironmentchoicesyouhavealreadymaderestrictyourAPIchoices
Theremaybe restrictionsonwhichAPIsyoucanusebecauseofoperatingsystem,programming language,orotherchoicesyouhavealreadymadeaboutyour applicationenvironment
Before choosinganAPI:listknownenvironment details,readtherestrictionsfortheAPIsyouareconsideringusing,andeliminatethoseAPIsthatare notsupportedwithyour environment
v AllAPIsmight notsupport thefunctionalityyour applicationsrequire.Theremaybe somefunctionalitythatyouwantforyour applicationsthatsomeAPIsdon’tsupport,ordon’tsupportwell
Trang 35Before choosinganAPI:listfunctionalitythatyouknowyouneed inyourapplications,readthesupportedfunctionalityof theAPIsyouare
consideringusing,andeliminatethoseAPIsthatdo notsupport thefunctionalityyouneed
2. OftheAPIsthathavenotbeeneliminated,compare desirablequalities
v SomeAPIsmight supportdesirablefunctionalitythatotherAPIsdo notsupport
Even ifmorethanoneAPIsupport thefunctionalityyouknowyourapplicationsrequire,oneAPImight supportfunctionalityyouare interested
tolearnmoreaboutandthatyoumightuseinthefuture
Before choosinganAPI:listandcompare thedesirable functionalitysupportedbytheAPIs
v SomeAPIsareeasier tolearnandsimplertousethanothers
IfmanyAPIs satisfyyour basicrequirements,choosing anAPIthatiseasierforyour developerstolearnand tousewillsaveyoudevelopmenttimeandmoney
Before choosinganAPI:learnaboutthearchitectureand designoftheAPIs,read thesupportingdocumentation,and chooseanAPIthatisintuitivetouseandwell documented
v Youmight alreadybe usinganAPIwithexistingapplications
Ifyouhaveexistingapplications,itmaysave youtimeormoneytousethesameAPIsthattheexistingapplicationsuse Thisisbecause,amongotherthings:
– yourdevelopersare familiarwiththeAPIstheyhaveusedbefore;
– youmightbeable toreusecodefromexistingapplications;and– yourdevelopment andproductionenvironmentswould alreadybeconfiguredtousethoseAPIs,soadditionalinstallationorconfigurationmightnotbe requiredtodevelop ordeploynewapplicationsusingthesameAPIs
Before choosinganAPI:investigatewhatAPIsarebeingusedbyexistingapplications
3. Consider changingyourrequirementsifanAPIisoutstanding
Insteadofchoosing yourAPIbased onenvironmentandapplicationrequirements,youmightchoosetoalteryourenvironment andapplicationdesigntosuitanAPI
WhilecomparingtherelativemeritsofdifferentAPIs,youmightdiscoverthatoneAPIsupportsfunctionalitythattheotherAPIsdon’tsupport andthatissodesirableyouwould choosetousethatAPIsolelybecauseofthatfunctionality.Ifyourenvironmentdoesn’tsupportthatAPI, youmightchoosetochangeyourenvironment.Ifyour applicationsdon’tevenrequirethatfunctionality,youmightchoose toredesignyour applicationstomakeuseofthefunctionality
Thereisriskinmakingchanges toyourenvironmentand applicationdesignforthesake ofanAPI However,theprocessofreviewingthefunctionality
ofthedifferentAPIs,and theprocessofconsideringyourrequirementsmightresultinan improveddatabaseapplication
BeforeeliminatinganAPIbecauseofenvironmentor applicationrestrictions,considerthemeritsofchangingyour requirementsand usingtheAPI
Related concepts:
Chapter 2 Support for elements of the database application development environment 29
Trang 36v “ApplicationTypesSupportedbytheIBMOLEDBProviderforDB2”in
Developing ADO.NET and OLE DB Applications
v “DB2.NET DataProviderdatabasesystem requirements”inDeveloping ADO.NET and OLE DB Applications
v “IBMOLE DBProviderrestrictions”inDeveloping ADO.NET and OLE DB Applications
v “LimitationsforADOapplications” inDeveloping ADO.NET and OLE DB Applications
v “HowtodeterminewhichtypeofIBM DB2DriverforJDBC andSQLJconnectivitytouse”inDeveloping Java Applications
v “Javaappletconsiderations”inDeveloping Java Applications
v “DeterminingwhentoexecuteSQLstatementsstaticallyordynamicallyinembeddedSQLapplications” inDeveloping Embedded SQL Applications
v “RestrictionsonembeddedSQLapplications” inDeveloping Embedded SQL Applications
v “ComparisonofDB2CLIand MicrosoftODBC”inCall Level Interface Guide and Reference, Volume 1
v “Considerationsfor mixingembedded SQLandDB2CLI” inCall Level Interface Guide and Reference, Volume 1
v “DB2CallLevelInterface(CLI)versusembedded SQL”onpage30
Related reference:
v “OLEDB.NETData Providerrestrictions”inDeveloping ADO.NET and OLE DB Applications
v “DriversupportforJDBCAPIs”inDeveloping Java Applications
v “Recommendationsfordevelopingembedded SQLapplicationswithXMLandXQuery”inDeveloping Embedded SQL Applications
v “Supportforelementsofthedatabaseapplication developmentenvironment”onpage5
Two importantdifferencesbetweenembedded SQLandDB2 CLIare:
1. themethodforbuildingapplications;
Tobuildanembeddedapplication:
a. connecttothetargetdatabase(s)andprecompiletheembeddedSQL;
b. compiletheapplicationcode;and
c. bind theapplicationtothetargetdatabase(s)
Afterthis,youcanruntheapplicationagainstthetarget database(s)
TobuildaCLIapplication:
a. compiletheapplicationcode
Afterthis,youcanruntheapplicationagainstanyDB2database towhichthebindfilesshippedwithCLIhavebeenbound
Becauseofthisdifference,deployingCLIapplicationsiseasier thandeployingembedded SQLapplications,particularlyinenvironmentswherethetarget databasesare notknown atbuildtimeorwherethetargetdatabasesmight change
and
Trang 372. itismucheasiertousestaticSQLinembedded SQLapplicationsthaninDB2CLIapplications.
Forthisreason,whetheryouusestaticSQLwillbea factorinchoosingwhethertouseembedded SQLorDB2CLI
Strengths and weaknesses of embedded SQL and DB2 CLI:
WhendecidingwhethertocreateyourapplicationsusingDB2CLIorembeddedSQL,considerthefollowingstrengthsandweaknessesofDB2CLIandembeddedSQL:
v DB2CLIapplicationsare easiertodeployand compatibleacrossdatabasemanagementsystems:
– Embedded SQLapplicationsmustbe precompiled,andare thereforedependant onprecompilersoftware.DB2CLIapplicationsdonotneedtobeprecompiled
– Youmust bindembeddedSQLapplicationstotarget databases,butyoudonotneedtobind CLIapplicationstotarget databases.Therearebind filesshippedwithDB2 CLIthatneed tobeboundtotarget databasesonceforallCLIapplications
– CLIprovidesa consistentinterfacetoquerycataloginformationcontained inDBMScatalogtables; andtheresultsetsreturnedare consistentacrossDBMSs.Thereisnosuchconsistentinterface availablewith embeddedSQL
v DB2CLIismoreflexible atruntime:
– Youcanuseparameter markersinCLIapplications,butnotinembeddedSQLapplications.CLIapplicationscanprocess statementswithparametermarkers,and obtaindatatypeinformationforthoseparametersusingdescribeinformation
– CLIprovidesenhancedparameterinputand fetchingcapability, allowingarrays ofdatatobespecifiedoninput,retrievingmultiplerowsofa resultsetdirectlyintoanarray,and executingstatementsthatgeneratemultiple resultsets
v SomefunctionalityiseasiertoachieveusingDB2CLIthanusingembeddedSQL:
– CLIobjectslikeconnectionhandlesallowyoutoeasilyconnecttomultipledatabases, andhavemultipleconnectionstothesame databaseinaCLIapplication.Todo thesame thinginanembeddedSQLapplication, youmustusemulti-threading,whichentailsusingDB2contextmanagementAPIstobethread-safe
See:MixedmultithreadedCLIapplications– Cursormanagement canbe easierwith DB2CLIthanwith embeddedSQL.For example,DB2CLIdoesnotrequiretheexplicit declarationofcursors,ithasapoolorcursorsthatget usedasneeded.Also,youdonotneedtoopencursors inCLIapplications,theexecutionofaSELECTstatement
automaticallycausesacursortobe opened.Finally,CLIhasmoreextensivesupport forscrollablecursors, includingusingscrollablecursorswitharrayoutput
– Embedded SQLapplicationsusecomplexdataareas,suchasSQLDAandSQLCA.DB2CLIprovideshandlestoreference thesamekindofinformation.For example,environmenthandles,connection handles,statementhandles,and descriptorhandlesprovideameanstorefertoinformationlikeglobalvariables,connectionspecific information,theparametersof anSQLstatement, orthecolumnsofa resultset
Chapter 2 Support for elements of the database application development environment 31
Trang 38– ItiseasiertoconvertbetweenvariousSQLandCdatatypesinDB2CLIapplicationsthaninembeddedSQLapplications,becauseDB2CLIprovidesextendeddataconversionsupportthatembedded SQLdoesnot.
v SomefunctionalityiseasiertoachieveusingembeddedSQLthanusingDB2CLI:
– Embedded SQLissupportedinlanguagesotherthanCorC++
– ItismucheasiertousestaticSQLinembedded SQLapplications
Strengths and weaknesses of static SQL and dynamic SQL:
WhenchoosingwhethertousestaticSQL,considerthefollowing:
v StaticSQLcanperformbetterthandynamicSQL:
InCLIapplications,dynamicSQLispreparedatruntime.InembeddedSQLapplications,staticSQLispreparedat precompiletime Theperformancecost
ofpreparingstatementsatruntimeis: 1)processingtheprepare(precompilingtheSQL);and 2)sendingtheprepare acrossthenetwork
Itisimportanttonotethatdespitethesecosts, staticSQLwillnotalwayshavebetterperformance thatdynamicSQL.Forexample,youcanavoidprecompilingdynamicSQLstatementsbycachingthestatements.Also,youcanavoidtheadditionalnetworktrafficofpreparingdynamicSQLbyusingdeferredprepare.Finally,databasestatisticsavailablewhenpreparingdynamicSQLat runtimemayresultina betteraccessplanthandatabasestatisticsavailablewhenpreparingstaticSQLat BINDtime.For example,theremaybenewindexesatruntime.Abetteraccessplanwouldresultinbetterperformance
v Implementingsecurityrulescanbeeasier withstaticSQLthanwithdynamicSQL:
WithstaticSQL,authorizationtoaccessobjectslike tablesandviewsisassociatedwith apackageand isvalidated atpackage bindingtime Thismeansthatadatabase administratorcangrant executeaccessforaset ofusersonaparticularpackage withouthavingtograntthose usersexplicitaccesstoeachdatabaseobject.WithdynamicSQL,authorizationisvalidated
atruntimeona perstatementbasis.Thismeansanadministratormustgrantexplicit accesstoeachdatabaseobject, whichpermitstheseusersaccesstopartsoftheobjectsthatthey donothavea needtoaccess
Static SQL in a DB2 CLI application:
ItispossibletousestaticSQLinDB2 CLIapplications:
v Usingstoredprocedureswith staticSQL
Itispossibletomakeuseof staticSQLwithin aCLIapplicationbycreating
a storedprocedurethatcontains thestaticSQL.Thestoredprocedureiscalledfromwithin aCLIapplicationand isexecutedontheserver.Once thestoredprocedureiscreated,anyCLIorODBCapplicationcancallit
v Mixingembedded SQLandDB2CLI
Itisalsopossibletowriteamixedapplicationthatusesbothembedded SQLandDB2 CLI.Inthiscase, CLIisusedtoprovidethebase application,withkeymoduleswritten inembeddedSQLusingstaticSQLforperformanceorsecurityreasons.Thiscomplicatestheapplicationdesign,andshouldonlybeusedifstoredproceduresdo notmeet theapplicationrequirements
See:Considerations formixingembeddedSQLandDB2 CLIanddbusemx.sqc Howtoexecuteembedded SQLstatementsinCLI
Trang 39Related concepts:
v “Choosingan applicationprogramminginterface”onpage28
v “Supporteddatabaseapplication programminginterfaces”onpage18
YoucandevelopDB2 databaseapplicationsinthefollowinglanguages:
howevertherearesomeminor differencesinprerequisitesandsupport.ToreviewthesupportedAPIsand programminglanguageforexternalroutinedevelopmentsee: SupportedAPIsand programminglanguagesforexternal routinedevelopment
Related reference:
v “Supportfordatabaseapplication developmentinFortran”onpage38
v “Supportfordatabaseapplication developmentinPerl”onpage39
v “Supportfordatabaseapplication developmentinPHP”onpage40
v “Supportfordatabaseapplication developmentinC”onpage34
v “Supportfordatabaseapplication developmentinC++”onpage35
v “Supportfordatabaseapplication developmentinCOBOL”onpage37
v “Supportfordatabaseapplication developmentinREXX”onpage41
v “Supportforelementsofthedatabaseapplicationdevelopment environment”onpage5
Todevelop anddeploy.NET applicationsthatrunagainstDB2databases,youwillneed tousesupporteddevelopmentsoftwareand operatingsystems
Supported operating systems for developing and deploying NET Framework 1.1 applications:
v Windows2000
v WindowsXP(32-bitedition)
v WindowsServer2003(32-bit edition)
Chapter 2 Support for elements of the database application development environment 33
Trang 40Note: Windows98,WindowsME,and WindowsNTarealsosupported, butonlyforrunningDB2client-sideapplications.
Supported operating systems for developing and deploying NET Framework 2.0 applications:
v Windows2000,ServicePack 3
v WindowsXP,ServicePack 2(32-bit and64-biteditions)
v WindowsServer2003(32-bit and64-bit editions)
Note: Windows98and WindowsMEarealso supported,butonlyforrunningDB2client-sideapplications
Supported development software for NET Framework applications:
Inadditiontoa DB2client,youwillneedoneofthefollowingoptionstodevelop.NET Frameworkapplications
v VisualStudio 2003(for.NETFramework1.1applications)
v VisualStudio 2005(for.NETFramework2.0applications)
v NETFramework1.1SoftwareDevelopmentKitand NETFrameworkVersion1.1RedistributablePackage(for.NET Framework1.1applications)
v NETFramework2.0SoftwareDevelopmentKitand NETFrameworkVersion2.0RedistributablePackage(for.NET Framework2.0applications)
Supported deployment software for NET Framework applications:
Inadditiontoa DB2client,youwillneedoneofthefollowingtwooptionstodeploy NETFrameworkapplications
v NETFrameworkVersion1.1RedistributablePackage (for.NETFramework1.1applications)
v NETFrameworkVersion2.0RedistributablePackage (for.NETFramework2.0applications)
The followingtable listsCcompilers thatare supportedforDB2 databaseapplication development
Unlessotherwisenoted,thecompilerslistedinthefollowingtablesupportboth32-bit and64-bit applicationdevelopment
Table 8 Supported C compilers
Operating System Supported Compiler(s)
AIX v IBMXLC/C++EnterpriseEditionVersion7.0forAIX
(withtheXLC/C++EnterpriseEditionVersion8.0runtimelibrary)
v IBMXLC/C++EnterpriseEditionVersion8.0forAIX
v IBMCforAIXVersion6.0
HPANSICCompilerVersionB.11.11.14HP-UXonIPF(IA64) v HPANSICCompilerVersionA.06.05