• No results found

DB2. Developing Java Applications. DB2 Version 9 SC

N/A
N/A
Protected

Academic year: 2021

Share "DB2. Developing Java Applications. DB2 Version 9 SC"

Copied!
401
0
0

Loading.... (view fulltext now)

Full text

(1)

DB

2

®

Developing

Java

Applications

DB2Version9

forLinux,UNIX,andWindows

(2)
(3)

DB

2

®

Developing

Java

Applications

DB2Version9

forLinux,UNIX,andWindows

(4)

Beforeusingthisinformationandtheproductitsupports,besuretoreadthegeneralinformationunderNotices.

EditionNotice

ThisdocumentcontainsproprietaryinformationofIBM.Itisprovidedunderalicenseagreementandisprotected bycopyrightlaw.Theinformationcontainedinthispublicationdoesnotincludeanyproductwarranties,andany statementsprovidedinthismanualshouldnotbeinterpretedassuch.

YoucanorderIBMpublicationsonlineorthroughyourlocalIBMrepresentative. v

Toorderpublicationsonline,gototheIBMPublicationsCenteratwww.ibm.com/shop/publications/order v

TofindyourlocalIBMrepresentative,gototheIBMDirectoryofWorldwideContactsatwww.ibm.com/ planetwide

ToorderDB2publicationsfromDB2MarketingandSalesintheUnitedStatesorCanada,call1-800-IBM-4YOU (426-4968).

WhenyousendinformationtoIBM,yougrantIBManonexclusiverighttouseordistributetheinformationinany wayitbelievesappropriatewithoutincurringanyobligationtoyou.

©CopyrightInternationalBusinessMachinesCorporation2006.Allrightsreserved.

(5)

Contents

Chapter

1.

Introduction

.

.

.

.

.

.

.

. 1

IntroductiontoJavaapplicationdevelopmentforDB2 1 SupporteddriversforJDBCandSQLJ . . . 1

SupportedJavaapplicationdevelopmentsoftware. . 3

SettinguptheDB2JDBCandSQLJdevelopment environment . . . 4

InstallingtheIBMDB2DriverforJDBCandSQLJ 4 DB2Binderutility. . . 8

DB2LobTableCreatorutility . . . 10

IBMDB2DriverforJDBCandSQLJ configurationpropertiescustomization . . . . 11

SpecialsetupforaccessingDB2forz/OSservers fromJavaprograms . . . 15

DB2T4XAIndoubtUtilfordistributedtransactions withDB2UDBforOS/390andz/OSVersion7 servers . . . 16

SpecialsetupforrunningJavaroutinesinthe HP-UXenvironment . . . 19

Chapter

2.

Programming

JDBC

applications

.

.

.

.

.

.

.

.

.

.

.

. 21

BasicstepsinwritingaJDBCapplication . . . . 21

ConnectingtodatabaseserversinJDBCapplications 24 HowJDBCapplicationsconnecttoadatasource 24 HowDB2applicationsconnecttoadatasource usingtheDriverManagerinterfacewiththeDB2 JDBCType2Driver . . . 25

Connectingtoadatasourceusingthe DriverManagerinterfacewiththeIBMDB2 DriverforJDBCandSQLJ . . . 27

Connectingtoadatasourceusingthe DataSourceinterface . . . 30

HowtodeterminewhichtypeofIBMDB2 DriverforJDBCandSQLJconnectivitytouse. . 32

JDBCconnectionobjects . . . 33

CreatinganddeployingDataSourceobjects. . . 33

JavapackagesforJDBCsupport . . . 35

Learningaboutadatasourceusing DatabaseMetaDatamethods . . . 35

VariablesinJDBCapplications . . . 37

ExecutingSQLstatementsinJDBCapplications . . 38

JDBCinterfacesforexecutingSQL. . . 38

UpdatingDB2tablesinJDBCapplications . . . 39

RetrievingdatafromDB2tablesinJDBC applications . . . 44

CallingstoredproceduresinJDBCapplications 52 WorkingwithLOBsinJDBCapplications . . . 57

ROWIDsinJDBCwiththeIBMDB2Driverfor JDBCandSQLJ . . . 61

DistincttypesinJDBCapplications . . . 61

SavepointsinJDBCapplications . . . 62

RetrievingidentitycolumnvaluesinJDBC applications . . . 63

ProvidingextendedclientinformationtotheDB2 serverwiththeIBMDB2DriverforJDBCand SQLJ . . . 66

WorkingwithXMLdatainJDBCapplications. . . 68

XMLdatainJDBCapplications. . . 68

XMLcolumnupdatesinJDBCapplications. . . 68

XMLdataretrievalinJDBCapplications. . . . 70

InvocationofroutineswithXMLparametersin Javaapplications . . . 72

JavasupportforXMLschemaregistrationand removal . . . 74

TransactioncontrolinJDBCapplications. . . 76

SettingtheisolationlevelforaJDBCtransaction 76 CommittingorrollingbackJDBCtransactions. . 76

HandlingerrorsandwarningsinJDBCapplications 77 HandlinganSQLExceptionundertheIBMDB2 DriverforJDBCandSQLJ . . . 77

HandlinganSQLWarningundertheIBMDB2 DriverforJDBCandSQLJ . . . 81

Retrievinginformationfroma BatchUpdateException. . . 82

HandlinganSQLExceptionundertheDB2JDBC Type2Driver. . . 84

HandlinganSQLWarningundertheDB2JDBC Type2Driver. . . 85

IBMDB2DriverforJDBCandSQLJclientreroute support. . . 86

DisconnectingfromdatabaseserversinJDBC applications . . . 88

Chapter

3.

Programming

SQLJ

applications

.

.

.

.

.

.

.

.

.

.

.

. 89

BasicstepsinwritinganSQLJapplication . . . . 89

ConnectingtoadatasourceusingSQLJ . . . 92

JavapackagesforSQLJsupport . . . 97

VariablesinSQLJapplications . . . 98

CommentsinanSQLJapplication. . . 99

ExecutingSQLstatementsinSQLJapplications . . 100

SQLstatementsinanSQLJapplication . . . . 100

UpdatingDB2tablesinSQLJapplications. . . 101

RetrievingdatafromDB2tablesinSQLJ applications . . . 111

CallingstoredproceduresinSQLJapplications 121 WorkingwithLOBsinSQLJapplications . . . 124

UsingSQLJandJDBCinthesameapplication 127 ControllingtheexecutionofSQLstatementsin SQLJ . . . 130

ROWIDsinSQLJwiththeIBMDB2Driverfor JDBCandSQLJ. . . 130

DistincttypesinSQLJapplications . . . 131

SavepointsinSQLJapplications . . . 132

WorkingwithXMLdatainSQLJapplications . . 133

XMLdatainSQLJapplications . . . 133

XMLcolumnupdatesinSQLJapplications . . 134

(6)

TransactioncontrolinSQLJapplications . . . . 137

SettingtheisolationlevelforanSQLJ transaction . . . 138

CommittingorrollingbackSQLJtransactions 138 HandlingerrorsandwarningsinSQLJapplications 138 HandlingSQLerrorsinanSQLJapplication . . 138

HandlingSQLwarningsinanSQLJapplication 139 ClosingtheconnectiontoadatasourceinanSQLJ application . . . 140

Chapter

4.

JDBC

and

SQLJ

security

141

SecurityundertheDB2JDBCType2Driver . . . 141

SecurityundertheIBMDB2DriverforJDBCand SQLJ . . . 142

UserIDandpasswordsecurityundertheIBMDB2 DriverforJDBCandSQLJ . . . 144

UserID-onlysecurityundertheIBMDB2Driver forJDBCandSQLJ . . . 146

EncryptedpasswordsecurityorencrypteduserID andencryptedpasswordsecurityundertheIBM DB2DriverforJDBCandSQLJ . . . 146

KerberossecurityundertheIBMDB2Driverfor JDBCandSQLJ. . . 148

IBMDB2DriverforJDBCandSQLJsecurity pluginsupport . . . 151

IBMDB2DriverforJDBCandSQLJtrusted contextsupport. . . 153

SecurityforpreparingSQLJapplicationswiththe IBMDB2DriverforJDBCandSQLJ. . . 155

Chapter

5.

Building

Java

database

applications

.

.

.

.

.

.

.

.

.

.

.

. 157

BuildingJDBCapplets . . . 157 BuildingJDBCapplications. . . 158 BuildingJDBCroutines . . . 158 BuildingSQLJapplets . . . 160 BuildingSQLJapplications . . . 162

Javaappletconsiderations . . . 163

SQLJapplicationandappletoptionsforUNIX . . 164

SQLJapplicationandappletoptionsforWindows 164 BuildingSQLJroutines . . . 165

SQLJroutineoptionsforUNIX . . . 166

SQLJroutineoptionsforWindows . . . 167

Chapter

6.

Java

sample

applications

169

JDBCsamples . . . 169

SQLJsamples . . . 174

Javaplug-insamples . . . 178

JavaWebSpheresamples . . . 179

Chapter

7.

Diagnosing

JDBC

and

SQLJ

problems

.

.

.

.

.

.

.

.

.

. 181

DiagnosingJDBCandSQLJproblemsunderthe IBMDB2DriverforJDBCandSQLJ. . . 181

JDBCandSQLJproblemdiagnosiswiththeIBM DB2DriverforJDBCandSQLJ . . . 181

Exampleofusingconfigurationpropertiesto startaJDBCtrace . . . 184

ExampleofatraceprogramundertheIBMDB2 DriverforJDBCandSQLJ . . . 184

SystemmonitoringfortheIBMDB2Driverfor JDBCandSQLJ. . . 189

DiagnosingJDBCandSQLJproblemsunderthe DB2JDBCType2Driver . . . 192

CLI/ODBC/JDBCtracefacility . . . 192

CLIandJDBCtracefiles. . . 197

Chapter

8.

Java

2

Platform,

Enterprise

Edition

.

.

.

.

.

.

.

.

.

.

.

.

.

. 207

Java2Platform,EnterpriseEditionOverview . . 207

Java2Platform,EnterpriseEdition . . . 207

Java2Platform,EnterpriseEditioncontainers . . 208

Java2Platform,EnterpriseEditionServer. . . . 209

Java2Platform,EnterpriseEditiondatabase requirements . . . 209

JavaNamingandDirectoryInterface(JNDI) . . . 209

Javatransactionmanagement . . . 209

ExampleofadistributedtransactionthatusesJTA methods . . . 210

EnterpriseJavaBeans. . . 215

Chapter

9.

JDBC

and

SQLJ

connection

pooling

support

.

.

.

.

. 219

Chapter

10.

IBM

DB2

Driver

for

JDBC

and

SQLJ

support

for

connection

concentrator

and

Sysplex

workload

balancing

.

.

.

.

.

.

.

.

.

.

.

.

. 221

JDBCconnectionconcentratorandSysplex workloadbalancing . . . 221

ExampleofenablingtheIBMDB2DriverforJDBC andSQLJconnectionconcentratorandSysplex workloadbalancing . . . 222

TechniquesformonitoringIBMDB2Driverfor JDBCandSQLJconnectionconcentratorand Sysplexworkloadbalancing . . . 224

Chapter

11.

JDBC

and

SQLJ

reference

227

DatatypesthatmaptoSQLdatatypesinJDBC applications . . . 227

PropertiesfortheIBMDB2DriverforJDBCand SQLJ . . . 232

DriversupportforJDBCAPIs. . . 247

SQLJstatementreference . . . 265 SQLJclause . . . 265 SQLJhost-expression. . . 266 SQLJimplements-clause. . . 266 SQLJwith-clause . . . 267 SQLJconnection-declaration-clause . . . 269 SQLJiterator-declaration-clause . . . 269 SQLJexecutable-clause . . . 271 SQLJcontext-clause . . . 272 SQLJstatement-clause . . . 272 SQLJSET-TRANSACTION-clause . . . 274 SQLJassignment-clause . . . 275 SQLJiterator-conversion-clause . . . 275 sqlj.runtimereference. . . 276

Summaryofinterfacesandclassesinthe sqlj.runtimepackage . . . 276

(7)

sqlj.runtime.ConnectionContextinterface . . . 277 sqlj.runtime.ForUpdateinterface . . . 282 sqlj.runtime.NamedIteratorinterface. . . 282 sqlj.runtime.PositionedIteratorinterface. . . . 283 sqlj.runtime.ResultSetIteratorinterface . . . . 283 sqlj.runtime.Scrollableinterface . . . 286 sqlj.runtime.AsciiStreamclass . . . 288 sqlj.runtime.BinaryStreamclass . . . 289 sqlj.runtime.CharacterStreamclass . . . 290 sqlj.runtime.ExecutionContextclass . . . 291 sqlj.runtime.SQLNullExceptionclass. . . 298 sqlj.runtime.StreamWrapperclass. . . 299 sqlj.runtime.UnicodeStreamclass . . . 300

IBMDB2DriverforJDBCandSQLJreference information . . . 300

DB2-onlyclassesandinterfaces . . . 301

JDBCdifferencesbetweentheIBMDB2Driver forJDBCandSQLJandotherDB2JDBCdrivers 335 SQLJdifferencesbetweentheIBMDB2Driver forJDBCandSQLJandotherDB2JDBCdrivers 342 ErrorcodesissuedbytheIBMDB2Driverfor JDBCandSQLJ. . . 344

SQLSTATEsissuedbytheIBMDB2Driverfor JDBCandSQLJ. . . 345

HowtofindIBMDB2DriverforJDBCand SQLJversionandenvironmentinformation . . 346

CommandsforSQLJprogrampreparation. . . . 347

sqlj-SQLJtranslator . . . 348

db2sqljcustomize-SQLJprofilecustomizer . . 351

db2sqljbind-SQLJprofilebinder. . . 361

db2sqljprint-SQLJprofileprinter . . . 367

Appendix

A.

DB2

Database

technical

information

.

.

.

.

.

.

.

.

.

.

.

. 369

OverviewoftheDB2technicalinformation . . . 369

Documentationfeedback . . . 369

DB2technicallibraryinhardcopyorPDFformat 370 OrderingprintedDB2books . . . 372

DisplayingSQLstatehelpfromthecommandline processor. . . 373

AccessingdifferentversionsoftheDB2 InformationCenter . . . 374

Displayingtopicsinyourpreferredlanguageinthe DB2InformationCenter. . . 374

UpdatingtheDB2InformationCenterinstalledon yourcomputerorintranetserver. . . 375

DB2tutorials . . . 377

DB2troubleshootinginformation. . . 377

TermsandConditions . . . 378

Appendix

B.

Notices

.

.

.

.

.

.

.

. 379

Trademarks . . . 381

Index

.

.

.

.

.

.

.

.

.

.

.

.

.

.

. 383

(8)
(9)

Chapter

1.

Introduction

Thefollowingtopics introduceJava applicationsupport fortheDB2 database system andexplainhowtoconfigureJava applicationsupport.

v “IntroductiontoJava applicationdevelopment forDB2”

v “Supporteddrivers forJDBCandSQLJ”

v “SupportedJava applicationdevelopmentsoftware”onpage3

v “SettinguptheDB2JDBCand SQLJdevelopmentenvironment”onpage4

Introduction

to

Java

application

development

for

DB2

TheDB2®databasesystemprovides driversupportforclientapplicationsand

applets thatarewritteninJava™usingJDBC,andforembedded SQLforJava

(SQLJ).

JDBC isan applicationprogramminginterface (API)thatJava applicationsuseto accessrelationaldatabases.DB2supportfor JDBCletsyouwriteJavaapplications thataccesslocalDB2dataorremoterelationaldataonaserverthatsupports DRDA®.

SQLJprovidessupport forembeddedstaticSQLinJavaapplications.SQLJwas initially developedbyIBM®,Oracle,and TandemtocomplementthedynamicSQL JDBC modelwitha staticSQLmodel.

Ingeneral,JavaapplicationsuseJDBCfordynamicSQLandSQLJforstaticSQL. However, becauseSQLJcaninter-operatewithJDBC,an applicationprogramcan useJDBCand SQLJwithin thesameunitofwork.

Related concepts:

v “Supporteddrivers forJDBCandSQLJ”onpage1

v “SupportedJava applicationdevelopmentsoftware”onpage3

Supported

drivers

for

JDBC

and

SQLJ

According totheJDBC specification,therearefourtypesofJDBC driver architectures:

Type1

DriversthatimplementtheJDBCAPIasa mappingtoanotherdataaccessAPI, suchasOpenDatabaseConnectivity(ODBC).Driversofthistype aregenerally dependentona nativelibrary,whichlimitstheirportability.TheDB2database system doesnotsupporta type1 driver.

Type2

Driversthatarewritten partlyintheJava programminglanguageandpartlyin nativecode.Thedrivers usea nativeclientlibraryspecific tothedatasourceto whichtheyconnect.Becauseofthenativecode,theirportabilityislimited.

Type3

(10)

database-independent protocol.Theserverthencommunicatestheclient’s requeststothedatasource.TheDB2databasesystem doesnotsupporta type 3 driver.

Type4

DriversthatarepureJava andimplementthenetworkprotocolfora specific datasource.Theclientconnectsdirectlytothedatasource.

DB2 Version9.1supportsadriverthatcombinestype2 andtype4 JDBC implementations.DB2Version9.1alsosupportsa.type2 driver,althoughthis support isdeprecated. TheDB2Version9.1type 2drivercontinuestousetheDB2 CLIinterface tocommunicatewithDB2 databaseservers.Thedriversthatare supportedinDB2Version9.1are:

DB2JDBCType2DriverforLinux®,UNIX®andWindows®(DB2JDBCtype2 driver)(deprecated):

The DB2JDBCtype2 driverletsJava applicationsmakecallstoDB2through JDBC. CallstotheDB2 JDBCtype2 driveraretranslatedtoJava nativemethods. The Javaapplicationsthatusethisdrivermust runona DB2client,throughwhich JDBC requestsflowtotheDB2 server.DB2Connect™Version9.1must beinstalled

before theDB2JDBCapplication drivercanbe usedtoaccessDB2UDB foriSeries datasources ordatasourcesintheDB2forOS/390® orz/OS®environments.

The DB2JDBCtype2 driversupportsthese JDBCandSQLJfunctions:

v MostofthemethodsthataredescribedintheJDBC1.2specification,andsome

ofthemethodsthataredescribed intheJDBC 2.0specification.SeeComparison ofdriversupportforJDBCAPIs.

v SQLJstatementsthatperform equivalentfunctionsto allJDBCmethods

v Connectionpooling

v Distributedtransactions

v Javauser-definedfunctionsandstoredprocedures

The DB2JDBCType2 DriverforLinux,UNIXandWindows willnotbesupported in futurereleasesoftheDB2databasesystem.Youshouldthereforeconsider moving totheIBM DB2DriverforJDBC andSQLJ.

IBMDB2DriverforJDBCandSQLJ(type2 andtype4):

The IBMDB2DriverforJDBC andSQLJisa singledriverthatincludesJDBCtype 2 andJDBC type4behavior, aswell asSQLJsupport.Whenanapplicationloads theIBM DB2DriverforJDBCand SQLJ,a singledriverinstanceisloadedfortype 2 andtype 4implementations.Theapplicationcanmaketype 2andtype 4

connectionsusingthissingledriverinstance.Thetype 2andtype 4connections canbe madeconcurrently.IBMDB2Driver forJDBCand SQLJtype 2driver behaviorisreferredto asIBM DB2DriverforJDBCandSQLJ type2 connectivity.

IBM DB2DriverforJDBC andSQLJtype4 driverbehaviorisreferredtoasIBM DB2 DriverforJDBCandSQLJtype4 connectivity.

The IBMDB2DriverforJDBC andSQLJsupportsthese JDBCandSQLJfunctions: v Allofthemethodsthatare describedintheJDBC3.0specifications.See

ComparisonofdriversupportforJDBCAPIs.

v SQLJstatementsthatperform equivalentfunctionsto mostJDBCmethods.

v Connectionsthatareenabled forconnectionpooling.WebSphere

®Application

(11)

v Javauser-definedfunctionsandstoredprocedures(IBM DB2DriverforJDBC

andSQLJtype2connectivity only).

v GlobaltransactionsthatrununderWebSphereApplicationServerVersion5.0

andabove.

v Supportfordistributed transactionmanagement.Thissupportimplements the

Java2Platform,EnterpriseEdition(J2EE)Java TransactionService(JTS)andJava TransactionAPI(JTA)specifications,whichconformtotheX/Openstandardfor distributedtransactions(DistributedTransactionProcessing:TheXASpecification,

availablefromhttp://www.opengroup.org).

Related concepts:

v “HowJDBCapplicationsconnecttoa datasource”onpage24

v “SecurityundertheIBMDB2Driver forJDBCand SQLJ”onpage142

Related reference:

v “Driversupport forJDBCAPIs”onpage247

v “JDBCdifferencesbetweentheIBMDB2 DriverforJDBCand SQLJand other

DB2JDBCdrivers”onpage335

v “SQLJdifferencesbetweentheIBM DB2DriverforJDBC andSQLJandother

DB2JDBCdrivers”onpage342

Supported

Java

application

development

software

Todevelop anddeployJava applicationsthatrunagainstDB2 databases,youneed tousesupporteddevelopmentsoftwareandoperatingsystems.

Whenyouinstall theIBMDB2Driver forJDBCandSQLJ, thedriverinstallation process doesnotinstall asoftwaredevelopment kit(SDK) forJava.Ifthe

installationprocess fortheDB2Databasefor Linux,UNIX,andWindows product installsanSDK forJava,thatinstallationprocessinstallsthelatestSDKforJava thatisavailable.

Thefollowingtablelists thesupportedlevelsoftheSDKforJava.Onlythelisted levelsand forward-compatiblelaterversionsofthesamelevelaresupported.For example,if onlylevel1.4.2islistedfora particularoperatingsystem,level1.4.2 SRn isalso supported,butlevel5isnotsupported.Iflevel1.4.2tolevel5islisted, level1.4.2SRnandlevel5SRm arealsosupported.

BecausetherearefrequentSDKfor Javafixesand updates,notalllevelsand versions havebeentested.Ifyour databaseapplicationhasproblemsthatare relatedtotheSDKforJava,try thenext availableversionofyour SDKforJava at thegivenlevel.

Non-IBMversions oftheSDK forJavaaresupportedonlyforbuildingand runningstand-aloneJava applications.For buildingand runningJava stored proceduresand user-definedfunctions,onlytheIBM SDKforJavathatisincluded with theDB2Databasefor Linux,UNIX,andWindows productissupported.

Table1.SDKforJavabyDB2DatabaseforLinux,UNIX,andWindows

Operatingsystem

31-bit,32-bit,or64-bitoperating

system SupportedlevelsoftheSDKforJava

AIX®5 32-bit/64-bit 1.4.2to5

(12)

Table1.SDKforJavabyDB2DatabaseforLinux,UNIX,andWindows (continued)

Operatingsystem

31-bit,32-bit,or64-bitoperating

system SupportedlevelsoftheSDKforJava

LinuxonIntel®

x86 32-bit 1.4.2to52

LinuxonIA64 64-bit 1.4.22,3

LinuxonAMD64/EM64T 32-bit/64-bit 1.4.2to52

LinuxonPowerPC®

32-bit/64-bit 1.4.2to5

LinuxonzSeries®

31-bit/64-bit 1.4.2to5

Solaris 32-bit/64-bit 1.4.22

WindowsonIntelx86 32-bit 1.4.2to52

WindowsonIA64 64-bit 1.4.22,3

Windowsonx64 32-bit/64-bit 1.4.2to52

Notes:

1. ThesamelevelsoftheSDKforJavathatareavailablefromHewlett-Packardaresupportedforbuildingand runningclientapplicationswiththeIBMDB2DriverforJDBCandSQLJ.

2. ThesamelevelsoftheSDKforJavathatareavailablefromSunMicrosystemsaresupportedforbuildingand runningclientapplicationswiththeIBMDB2DriverforJDBCandSQLJ.

3. AminimumlevelofSDKforJava1.4.2SR3isrequiredforMontecitoprocessors.

Related tasks:

v “InstallingtheIBM DB2DriverforJDBC andSQLJ”onpage4

Setting

up

the

DB2

JDBC

and

SQLJ

development

environment

The followingtopics containinformationonsettinguptheenvironmentforJava application programmingonDB2DatabaseforLinux,UNIX,andWindows. v “InstallingtheIBM DB2DriverforJDBC andSQLJ”

v “DB2Binderutility”onpage8

v “DB2LobTableCreatorutility”onpage10

v “IBMDB2 DriverforJDBCand SQLJconfigurationpropertiescustomization”on

page11

v “SpecialsetupforaccessingDB2 forz/OSserversfromJava programs”onpage

15

v “DB2T4XAIndoubtUtilfordistributed transactionswithDB2UDBfor OS/390

andz/OSVersion7servers”onpage16

v “SpecialsetupforrunningJavaroutines intheHP-UX environment”onpage19

Installing

the

IBM

DB2

Driver

for

JDBC

and

SQLJ

Followthese stepstoinstall theIBMDB2DriverforJDBC andSQLJ.

Prerequisites:

v AnSDKforJava,1.4.2orlater.

ForallDB2productsexcepttheDB2RuntimeClient,theinstallationprocess automaticallyoroptionallyinstallsanSDKforJava.

v JVMnativethreadssupport

AnyJVMs thatrunJavaapplicationsthataccessDB2databasesmustinclude nativethreadssupport.Youcanspecifynativethreads asthedefaultthread supportforsomeJVMsbysettingtheTHREADS_FLAGenvironmentvariable to

(13)

″native″.Refertothedocumentationforyour Javaenvironmentforinstructions onmaking nativethreadsthedefaultonyoursystem.

v SupportforaccessingDB2 forz/OSdatabaseservers

IfyouplantoaccessDB2for z/OSdatabaseserverswith yourJavaapplications, followtheinstructionsinSpecialsetupforaccessingDB2 forz/OSserversfrom Javaprograms.

v Unicodesupport foriSeries

servers

IfanySQLJorJDBCprogramswilluseIBM DB2DriverforJDBC andSQLJtype 4connectivitytoconnecttoa DB2UDBforiSeries server,theOS/400®operating systemmustsupport theUnicodeUTF-8encodingscheme.Thefollowingtable liststheOS/400PTFsthatyouneedforUnicodeUTF-8support:

Table2.OS/400PTFsforUnicodeUTF-8support

OS/400version PTFnumbers

V5R3orlater None(supportisincluded)

V5R2 SI06541,SI06796,SI07557,SI07564,SI07565,

SI07566,andSI07567

V5R1 SI06308,SI06300,SI06301,SI06302,SI06305,

SI06307,andSI05872

v JavasupportforHP-UXclients andservers

HP-UXservers:TheIBMDB2 DriverforJDBCand SQLJdoesnotsupport databasesthatareintheHP-UXdefaultcharacterset,Roman8.Therefore,when youcreatea databaseonanHP-UXserverthatyouplantoaccesswith theIBM DB2DriverforJDBC andSQLJ,youneedtocreatethedatabasewitha different characterset.

HP-UXclientsand servers:TheJavaenvironmentonanHP-UXsystem requires specialsetuptorunstoredproceduresundertheIBMDB2Driver forJDBCand SQLJ.

SeeSpecialsetupforrunningJavaroutinesintheHP-UXenvironmentfor details.

Procedure:

1. DuringtheDB2DatabaseforLinux,UNIX,andWindowsinstallationprocess,

selectJava support onUNIXor Linux,orJDBC supporton Windows.These selections aredefaults.IfyouhavealreadyinstalledDB2DatabaseforLinux, UNIX,and WindowswithoutJDBC support,youcanruntheinstallation process inCustommodetoaddJDBCsupport.

Selection of Javasupport orJDBC support causestheinstallation process to perform thefollowingactions:

v InstalltheIBMDB2DriverforJDBC andSQLJclassfiles,andtomodifythe

CLASSPATHtoincludethem.

Thefilesareplacedinthesqllib\javadirectoryforWindowssystems, orthe sqllib/javadirectoryforUnixorLinuxsystems.

Thefilesnamesaredb2jcc.jarand sqlj.zip.Youneedonlydb2jcc.jarfor preparingand executingJDBC programs.Youneeddb2jcc.jar andsqlj.zip forpreparingand executingSQLJprograms.

v InstallIBMDB2Driver forJDBCandSQLJlicensefiles,andmodifythe

CLASSPATHtoincludethem.

Thefilesareplacedinthesqllib\javadirectoryforWindowssystems, orthe sqllib/javadirectoryforUnixorLinuxsystems. Thefilenamesare:

(14)

Table3.IBMDB2DriverforJDBCandSQLJlicensefiles

Licensefile

Servertowhichlicensefilepermits

aconnection Productthatincludeslicensefile

db2jcc_license_c.jar Cloudscape

CloudscapeNetworkServer

db2jcc_license_cu.jar Cloudscape

AllDB2DatabaseforLinux, UNIX,andWindowsservers

AllDB2DatabaseforLinux,UNIX, andWindowsproducts

db2jcc_license_cisuz.jar Cloudscape

AllDB2DatabaseforLinux, UNIX,andWindowsservers DB2forz/OS

DB2UDBforiSeries

AllDB2Connectproducts

v InstallIBMDB2Driver forJDBCandSQLJnativelibrariesforsupport of

IBMDB2Driver forJDBCandSQLJtype2 connectivity.

Thefilesareplacedinthesqllib\bindirectoryforWindows systems,orthe sqllib/libdirectoryforUnixor Linuxsystems.

Thefilenamesare:

libdb2jcct2.so

ForAIX, HP-UXonIPF,Linux,and Solaris

libdb2jcct2.sl

ForHP-UXonPA-RISC

db2jcct2.dll

ForWindows

2. Customize thedriver-wideconfigurationproperties,if anyofthedefaultsare

inappropriate.See IBMDB2DriverforJDBC andSQLJconfiguration propertiescustomizationfordetails.

3. ConfigureTCP/IP

Serversmust beconfiguredforTCP/IPcommunicationinthefollowingcases: v JDBCorSQLJapplicationsthatuseIBMDB2 DriverforJDBCand SQLJ

type4connectivity.

v JDBCorSQLJapplicationsthatuseIBMDB2 DriverforJDBCand SQLJ

type2connectivity, andspecifyserverandportintheconnectionURL. Ensure thattheTCP/IPlistenerisrunning. ToactivatetheTCP/IPlistener: a. SettheenvironmentvariableDB2COMMtoTCPIP:

db2set DB2COMM=TCPIP

b. Updatethedatabasemanager configurationfilewith theTCP/IPservice

nameasspecifiedintheservices file:

db2 update dbm cfg using SVCENAME TCP/IP-service-name

Youmustexecutethedb2stopand db2startcommandsforthissettingto takeeffect.

The portnumber usedforapplets andSQLJprogramsneedstobe thesameas theTCP/IPSVCENAMEnumberusedinthedatabase managerconfiguration file.

4. On DB2DatabaseforLinux,UNIX,and Windowsserversonwhichyouplan

to runJavastored proceduresoruser-definedfunctions,updatethedatabase manager configurationtoinclude thepathwheretheSDKforJavaislocated. Youcandothis byenteringcommandssimilartothese ontheserver

(15)

Fordatabasesystems onUNIXorLinux:

db2 update dbm cfg using JDK_PATH /home/db2inst/jdk142

/home/db2inst/jdk142isthepathwheretheSDKforJavaisinstalled.

Fordatabasesystems onWindows:

db2 update dbm cfg using JDK_PATH c:\Program Files\jdk142

c:\ProgramFiles\jdk142isthepathwheretheSDKforJavaisinstalled.

Toverify thecorrectvalue fortheJDK_PATHfieldin theDB2database manager configuration, enterthefollowingcommandonthedatabaseserver:

db2 get dbm cfg

Youmight wanttoredirecttheoutputtoafileforeasierviewing.The JDK_PATHfieldappears nearthebeginningoftheoutput.

5. Ifyouplanto callSQLproceduresthatare onDB2DatabaseforLinux,UNIX,

and WindowsserversfromJava programs,andthedateand timeformatthat isassociatedwith theterritorycodeofthedatabaseserversisnottheUSA format, takethefollowingactions:

a. SettheDB2_SQLROUTINE_PREPOPTSregistryvariableonthedatabase

serverstoindicatethatthedefaultdatetimeformatisISO:

db2set DB2_SQLROUTINE_PREPOPTS="DATETIME ISO"

b. RedefineanyexistingSQLproceduresthatyouplantocallfromJava

programs.

Thesestepsarenecessarytoensurethatthecallingapplicationreceivesdate and timevaluescorrectly.

6. Ifyouplanto runJavastored proceduresthatworkwith XMLdataonDB2

DatabaseforLinux,UNIX,andWindowsservers,youneedtosettheIBM DB2 DriverforJDBCand SQLJasthedefaultJDBCdriverforrunningstored procedures.Todothat,settheDB2_USE_DB2JCCT2_JROUTINEenvironment value toYES,yes,ON,on,TRUE,true,or1.For example:

Toset theIBMDB2DriverforJDBC andSQLJasthedefaultdriverat the instance level:

db2set DB2_USE_DB2JCCT2_JROUTINE=YES -i instance-name

Toset theIBMDB2DriverforJDBC andSQLJasthedefaultdriverat the globallevel:

db2set DB2_USE_DB2JCCT2_JROUTINE=YES -g

7. Ifyouplanto useKerberossecurity,putthefollowingfilesintheJava

application CLASSPATH: v ibmjceprovider.jar v ibmjcefw.jar v ibmjlog.jar v US_export_policy.jar v Local_policy.jar v ibmjgssprovider.jar v jaas.jar v ibmjceprovider.jar v ibmjcefw.jar v ibmjlog.jar v US_export_policy.jar v Local_policy.jar

(16)

8. IfyouintendtoconnecttoaDB2 forz/OSserver,runthe

com.ibm.db2.jcc.DB2Binder utilitytobindtheDB2packagesthatareusedat theserverbytheIBM DB2DriverforJDBC andSQLJ. SeeDB2Binderutility for details.

9. Determine whetheryouneedtouseLOBlocatorstoaccessthefollowing

typesofdataonDB2forz/OS servers: v DatainDBCLOB columns

v DatainCLOBcolumns

Ifso, youneedtocreatetablesonthedatabaseserversthatareneededfor fetchingdatafromDBCLOB orCLOBcolumns usingLOB locators.Createthe tablesinoneofthefollowingways:

v OntheDB2forz/OSservers,customize andrunjobDSNTIJMS.Thatjobis

locatedindatasetprefix.SDSNSAMP.

v Ontheclient,runthecom.ibm.db2.jcc.DB2LobTableCreatorutilityagainst

eachoftheDB2forz/OSservers.SeeDB2LobTableCreatorutilityfor details.

10. If youplantouseIBMDB2 DriverforJDBCand SQLJtype 4connectivityto

implement distributedtransactionsagainstDB2 forz/OSVersion7servers, runtheDB2T4XAIndoubtUtilutilityonceforeachofthoseDB2forz/OS Version7 servers.SeeDB2T4XAIndoubtUtilutilityfordetails.

Related concepts:

v “IBMDB2 DriverforJDBCand SQLJconfigurationpropertiescustomization”on

page11

v “SupportedJava applicationdevelopmentsoftware”onpage3

Related tasks:

v “SpecialsetupforrunningJavaroutines intheHP-UX environment”onpage19

v “ConfiguringTCP/IPcommunicationsfora DB2instance”inInstallationand ConfigurationSupplement

v “Updatingthedatabase managerconfigurationfileontheserverforTCP/IP

communications”inInstallationandConfigurationSupplement

v “Updatingtheservices fileontheserverforTCP/IPcommunications”in Installationand ConfigurationSupplement

v “SpecialsetupforaccessingDB2 forz/OSserversfromJava programs”onpage

15

Related reference:

v “DB2Binderutility”onpage8

v “DB2LobTableCreatorutility”onpage10

v “IBMSoftwareDevelopmentKitforJavalevelsforDB2 products”inQuick BeginningsforDB2 Servers

v “DB2T4XAIndoubtUtilfordistributed transactionswithDB2UDBfor OS/390

andz/OSVersion7servers”onpage16

v “DB2Connectproductofferings”inDB2ConnectUser’sGuide

DB2Binder

utility

The DB2BinderutilitybindstheDB2packagesthatareusedatthedatabaseserver bytheIBMDB2Driver forJDBCandSQLJ, andgrantsEXECUTEauthorityonthe packagestoPUBLIC.

(17)

DB2Binder syntax:

 java com.ibm.db2.jcc.DB2Binder -url jdbc:db2://server /database : port

-user user-ID 

 -password password

-size integer -collection collection-name

   , -tracelevel trace-option -action add

-action replace -help



DB2Binder optiondescriptions: -url

SpecifiesthedatasourceatwhichtheJCCpackagesaretobe bound.The variable partsof the-urlvalue are:

server

ThedomainnameorIPaddressoftheMVS™system onwhichtheDB2 subsystemresides.

port

TheTCP/IPserverportnumberthatisassignedtotheDB2 subsystem. Thedefaultis446.

database

ThelocationnamefortheDB2 subsystem,asdefinedinthe SYSIBM.LOCATIONScatalog table.

-user

SpecifestheuserIDunderwhichthepackagesaretobe bound.Thisuser must haveBINDauthorityonthepackages.

-size

SpecifiesthenumberofDB2 packagesthatDB2binderbindsforeachofthe fourDB2 isolationlevelsand eachofthetwoholdabilityvalues.TheIBMDB2 Driver forJDBCandSQLJusesthesepackagestoprocessdynamicSQL.In addition,theDB2binderbindsasinglepackage thattheIBM DB2Driverfor JDBC andSQLJusesforstaticSQL.Therefore,thetotalnumberofpackages thatDB2binderbindsis:

4*2*integer+1

Thedefaultvalue forintegeris3.

-collection

SpecifiesthecollectionIDforthepackagesthatare usedbyaninstanceof the IBM DB2DriverforJDBC andSQLJ.ThedefaultisNULLID.DB2binder translatesthisvalue touppercase.

YoucancreatemultipleinstancesoftheJCCpackageset ata singlelocationby runningcom.ibm.db2.jcc.DB2Bindermultipletimes,andspecifying adifferent value for-collectioneachtime.Atruntime,youselecta copyoftheIBMDB2 Driver forJDBCandSQLJbysettingthecurrentPackageSetpropertytoa value thatmatchesa -collectionvalue.

(18)

-tracelevel

SpecifieswhattotracewhileDB2Binderruns.

-action

SpecifieswhethertheIBMDB2 DriverforJDBCand SQLJpackagescanbe replaced.

add Indicatesthatapackage canbecreatedonlyifitdoesnotalreadyexist. Addisthedefault.

replace

Indicatesthatapackage canbecreatedevenifapackage withthe samenamealreadyexists.Thenew packagereplacestheoldpackage.

ReferenceText

Related tasks:

v “InstallingtheIBM DB2DriverforJDBC andSQLJ”onpage4

DB2LobTableCreator

utility

The DB2LobTableCreatorutilitycreates tablesona DB2forz/OSdatabaseserver thatare requiredbyJDBCorSQLJapplicationsthataccessthefollowingtypesof datausingLOBlocators:

v DatainDBCLOBcolumns

v DatainCLOBcolumns

DB2LobTableCreatorsyntax:

 java com.ibm.db2.jcc.DB2LobTableCreator -url jdbc:db2: //server /database :port



 -user user-ID -password password

-help



DB2LobTableCreatoroptiondescriptions: -url

SpecifiesthedatasourceatwhichDB2LobTableCreatoristorun.Thevariable partsofthe-urlvalueare:

jdbc:db2:

IndicatesthattheconnectionistoaserverintheDB2family.

server

ThedomainnameorIPaddressofthedatabaseserver.

port

TheTCP/IPserverportnumberthatisassignedtothedatabaseserver. Thisisanintegerbetween0 and65535.Thedefaultis446.

database

Anameforthedatabaseserver.

databaseistheDB2locationnamethatisdefinedduringinstallation.All characters inthisvaluemust beuppercase characters.Youcandetermine thelocationnamebyexecutingthefollowingSQLstatementontheserver:

(19)

-user

SpecifestheuserIDunderwhichDB2LobTableCreatoristorun.Thisuser must haveauthoritytocreatetablesintheDSNATPDBdatabase.

-password

SpecifesthepasswordfortheuserID.

-help

SpecifiesthattheDB2LobTableCreatorutilitydescribeseachoftheoptionsthat it supports.Ifanyotheroptionsarespecifiedwith -help,theyareignored.

Related tasks:

v “InstallingtheIBM DB2DriverforJDBC andSQLJ”onpage4

IBM

DB2

Driver

for

JDBC

and

SQLJ

configuration

properties

customization

TheIBM DB2DriverforJDBC andSQLJconfigurationpropertiesletyouset propertyvaluesthathavedriver-widescope.Thosesettingsapply across

applicationsand DataSourceinstances.Youcanchangethesettingswithouthaving tochangeapplication sourcecodeorDataSourcecharacteristics.

EachIBM DB2DriverforJDBC andSQLJconfigurationpropertysettingisofthis form:

property=value

property canhaveoneormore ofthefollowingforms: v db2.jcc.override.property-name

v db2.jcc.property-name

v db2.jcc.default.property-name

Iftheconfigurationpropertybeginswith db2.jcc.override,theconfiguration propertyisapplicabletoallconnectionsandoverridesanyConnectionor DataSourcepropertywith thesame property-name.Iftheconfigurationproperty begins withdb2.jccordb2.jcc.default,theconfigurationpropertyvalueisa default. ConnectionorDataSourcepropertysettingsoverridethatvalue.

Youcansetconfigurationpropertiesinthefollowingways:

v SettheconfigurationpropertiesasJava systemproperties.Thosesettings

overrideanyothersettings.

Forstand-aloneJava applications,youcansettheconfigurationpropertiesas Javasystempropertiesbyspecifying -Dproperty=valueforeachconfiguration propertywhenyouexecutethejavacommand.

v Settheconfigurationpropertiesinaresourcewhosenameyouspecifyinthe

db2.jcc.propertiesFileJavasystemproperty.For example,youcanspecifyan absolutepathnameforthedb2.jcc.propertiesFilevalue.

Forstand-aloneJava applications,youcansettheconfigurationpropertiesby specifyingthe-Ddb2.jcc.propertiesFile=pathoptionwhenyouexecutethejava command.

v Settheconfigurationpropertiesinaresourcenamed

DB2JccConfiguration.properties.AstandardJavaresourcesearchisusedto find DB2JccConfiguration.properties.TheIBMDB2Driver forJDBCandSQLJ searchesforthisresourceonlyifyouhavenotset thedb2.jcc.propertiesFileJava systemproperty.

(20)

DB2JccConfiguration.propertiescanbea stand-alonefile,oritcanbeincludedin aJARfile.

IftheDB2JccConfiguration.propertiesfileisin theISO8859-1(Latin-1)encoding scheme,orisintheLatin-1encodingscheme withsomeUnicode-encoded (\udddd)characters,youdo notneed todocharacterconversionbefore theIBM DB2DriverforJDBC andSQLJcanusethefile.Ifthe

DB2JccConfiguration.propertiesfileisinsomeotherencoding scheme,youneed tousetheJavanative2asciiconvertertoconvertthecontentstoLatin-1or Unicode-encodedcharacters.

IfDB2JccConfiguration.propertiesisastand-alone file,thepathfor

DB2JccConfiguration.propertiesmust beintheCLASSPATHconcatenation. IfDB2JccConfiguration.propertiesisinaJARfile,theJARfilemustbe inthe CLASSPATHconcatenation.

YoucansetanyofthefollowingIBMDB2Driver forJDBCandSQLJconfiguration properties.All propertiesare optional.

db2.jcc.currentSchemaordb2.jcc.override.currentSchema

Specifiesthedefaultschemanamethatisusedtoqualifyunqualifieddatabase objectsindynamically preparedSQLstatements.Thisvalueofthisproperty setsthevalueintheCURRENTSCHEMAspecialregisterona DB2server.

db2.jcc.currentSQLIDordb2.jcc.override.currentSQLID

Specifies:

v TheauthorizationIDthatisusedforauthorizationcheckingondynamically

preparedCREATE,GRANT,and REVOKESQLstatements.

v Theownerofa tablespace,database,storagegroup,orsynonymthatis

createdbya dynamicallyissuedCREATEstatement.

v Theimplicitqualifierofalltable,view,alias,andindexnamesspecifiedin

dynamicSQLstatements.

currentSQLID setsthevalue intheCURRENTSQLID specialregisteronaDB2 forz/OS server.IfthecurrentSQLIDpropertyisnotset,thedefaultschema nameisthevalue intheCURRENTSQLIDspecialregister. Thisproperty appliesonlytoIBMDB2Driver forJDBCandSQLJtype4 connectivitytoa DB2 forz/OSserver.

db2.jcc.dumpPool

Specifiesthetypesofstatisticsonglobaltransportpooleventsthatarewritten, inaddition tosummarystatistics.Theglobaltransport poolisusedforthe connection concentratorandSysplexworkloadbalancing.

Thedatatype ofdb2.jcc.dumpPoolisint. db2.jcc.dumpPoolStatisticsOnScheduleand

db2.jcc.dumpPoolStatisticsOnScheduleFilemust alsobe setforwritingstatistics before anystatisticsarewritten.

Youcanspecifyoneormoreofthefollowingtypesofstatisticswith the db2.jcc.dumpPool property:

v DUMP_REMOVE_OBJECT(hexadecimal:X'01',decimal:1)

v DUMP_GET_OBJECT(hexadecimal:X'02',decimal:2)

v DUMP_WAIT_OBJECT(hexadecimal: X'04',decimal: 4)

v DUMP_SET_AVAILABLE_OBJECT(hexadecimal:X'08',decimal:8)

v DUMP_CREATE_OBJECT(hexadecimal: X'10',decimal: 16)

v DUMP_SYSPLEX_MSG(hexadecimal:X'20',decimal:32)

(21)

Totracemore thanonetype ofevent,addthevaluesforthetypesofevents thatyouwanttotrace.For example,supposethatyouwanttotrace

DUMP_GET_OBJECTand DUMP_CREATE_OBJECTevents. Thenumeric equivalents ofthesevaluesare2 and16,soyouspecify18forthe

db2.jcc.dumpPool value.

Thedefaultis0,whichmeansthatonlysummarystatisticsfortheglobal transport poolare written.

db2.jcc.dumpPoolStatisticsOnSchedule

Specifieshow often,inseconds, globaltransport poolstatisticsarewritten to thefilethatisspecifiedbydb2.jcc.dumpPoolStatisticsOnScheduleFile.The globaltransport objectpoolisusedfortheconnectionconcentratorand Sysplexworkloadbalancing.

Thedefaultis-1.-1 meansthatglobaltransportpoolstatisticsarenotwritten.

db2.jcc.dumpPoolStatisticsOnScheduleFile

Specifiesthenameofthefiletowhichglobaltransportpoolstatisticsare written.The globaltransport poolisusedfortheconnectionconcentratorand Sysplexworkloadbalancing.

Ifdb2.jcc.dumpPoolStatisticsOnScheduleFileisnotspecified,globaltransport poolstatisticsarenotwritten.

db2.jcc.maxTransportObjectIdleTime

Specifiestheamountof timeinsecondsthatanunusedtransport objectstays ina globaltransportobjectpoolbefore itcanbedeletedfromthepool. Transport objectsareusedfortheconnectionconcentrator andSysplex workloadbalancing.

Thedefaultvalue fordb2.jcc.maxTransportObjectIdleTimeis60.Setting db2.jcc.maxTransportObjectIdleTimetoa valuelessthan0 causesunused transport objectstobedeletedfromthepoolimmediately.Doingthis isnot

recommended becauseitcancausesevereperformance degradation.

db2.jcc.maxTransportObjects

Specifiestheupperlimitforthenumberoftransport objectsinaglobal transport objectpoolfortheconnectionconcentratorandSysplexworkload balancing.Whenthenumberoftransportobjectsinthepoolreachesthe db2.jcc.maxTransportObjects value,transportobjectsthathavenotbeenused forlongerthanthedb2.jcc.maxTransportObjectIdleTimevalue aredeletedfrom thepool.

Thedefaultvalue fordb2.jcc.maxTransportObjectsis-1.Anyvalue thatisless thanorequal to0meansthatthereisnolimittothenumberoftransport objectsintheglobaltransportobjectpool.

db2.jcc.maxTransportObjectWaitTime

Specifiesthemaximumamount oftimeinsecondsthatanapplicationwaitsfor a transportobjectifthedb2.jcc.maxTransportObjectsvalue hasbeenreached. Transport objectsareusedfortheconnectionconcentrator andSysplex workloadbalancing.Whenanapplication waitsforlongerthanthe

db2.jcc.maxTransportObjectWaitTime value,theglobaltransportobjectpool throws anSQLException.

Thedefaultvalue fordb2.jcc.maxTransportObjectWaitTimeis-1.Anynegative value meansthatapplicationswait forever.

db2.jcc.minTransportObjects

(22)

transport objectpoolfortheconnectionconcentratorand Sysplexworkload balancing.WhenaJVMiscreated,thereare notransportobjectsinthepool. Transport objectsareaddedtothepoolastheyare needed.Afterthe

db2.jcc.minTransportObjects valueisreached,thenumber oftransportobjects intheglobaltransportobjectpoolnevergoesbelow the

db2.jcc.minTransportObjects valueforthelifetimeof thatJVM.

Thedefaultvalue fordb2.jcc.minTransportObjectsis0.Anyvalue thatisless thanorequal to0meansthattheglobaltransportobjectpoolcanbecome empty.

db2.jcc.traceDirectoryordb2.jcc.override.traceDirectory

Enables theIBMDB2Driver forJDBCandSQLJtraceforJavadrivercode,and specifies adirectoryinto whichtraceinformationiswritten.When

db2.jcc.override.traceDirectoryisspecified,traceinformationformultiple connectionsonthesameDataSourceiswritten tomultiplefiles.

Whendb2.jcc.override.traceDirectoryisspecified,a connectionistracedtoa filenamedfile-name_origin_n.

n isthenthconnectionfora DataSource.

Ifneitherdb2.jcc.traceFileNamenordb2.jcc.override.traceFileNameisspecified,

file-nameistraceFile.Ifdb2.jcc.traceFileNameordb2.jcc.override.traceFileName isalsospecified,file-nameisthevalue ofdb2.jcc.traceFileNameor

db2.jcc.override.traceFileName.

originindicatestheoriginofthelogwriterthatisinuse.Possiblevaluesof

originare:

cpds ThelogwriterforaDB2ConnectionPoolDataSourceobject.

driver ThelogwriterforaDB2Driver object.

global ThelogwriterforaDB2TraceManager object.

sds ThelogwriterforaDB2SimpleDataSource object.

xads ThelogwriterforaDB2XADataSource object.

Thedb2.jcc.override.traceDirectorypropertyoverridesthetraceDirectory propertyfor aConnectionorDataSourceobject.

For example,specifyingthefollowingsettingfordb2.jcc.override.traceDirectory enablestracingoftheIBMDB2 DriverforJDBCand SQLJJava codetofilesin a directorynamed/SYSTEM/tmp:

db2.jcc.override.traceDirectory=/SYSTEM/tmp

Youshouldsetthetracepropertiesunderthedirectionof IBMSoftware Support.

db2.jcc.sqljUncustomizedWarningOrException

SpecifiestheactionthattheIBMDB2Driver forJDBCandSQLJtakeswhenan uncustomized SQLJapplication runs.

db2.jcc.sqljUncustomizedWarningOrExceptioncanhavethefollowingvalues:

0 TheIBM DB2DriverforJDBC andSQLJdoesnotthrowa Warningor Exception whenanuncustomizedSQLJapplicationisrun.Thisisthe default.

1 TheIBM DB2DriverforJDBC andSQLJthrowsaWarning whenan uncustomizedSQLJapplication isrun.

(23)

2 TheIBM DB2DriverforJDBC andSQLJthrowsanExceptionwhenan uncustomizedSQLJapplication isrun.

db2.jcc.traceFileordb2.jcc.override.traceFile

Enables theIBMDB2Driverfor JDBCandSQLJtraceforJavadrivercode,and specifies thenameonwhichthetracefilenamesare based.

Specify afullyqualifiedfilenameforthedb2.jcc.override.traceFileproperty value.

Thedb2.jcc.override.traceFilepropertyoverridesthetraceFile propertyfora ConnectionorDataSourceobject.

For example,specifyingthefollowingsettingfordb2.jcc.override.traceFile enablestracingoftheIBMDB2 DriverforJDBCand SQLJJava codetoafile named/SYSTEM/tmp/jdbctrace:

db2.jcc.override.traceFile=/SYSTEM/tmp/jdbctrace

Youshouldsetthetracepropertiesunderthedirectionof IBMSoftware Support.

db2.jcc.traceFileAppend ordb2.jcc.override.traceFileAppend

Specifieswhethertoappend tooroverwritethefilethatisspecifiedbythe db2.jcc.override.traceFileproperty.Thedatatypeofthis propertyisboolean. Thedefaultisfalse,whichmeansthatthefilethatisspecifiedbythetraceFile propertyisoverwritten.

Thedb2.jcc.override.traceFileAppend propertyoverridesthetraceFileAppend propertyfora ConnectionorDataSourceobject.

For example,specifyingthefollowingsettingfor

db2.jcc.override.traceFileAppend causestrace datatobeaddedtotheexisting tracefile:

db2.jcc.override.traceFileAppend=true

Youshouldsetthetracepropertiesunderthedirectionof IBMSoftware Support.

Related reference:

v “PropertiesfortheIBMDB2DriverforJDBC andSQLJ”onpage232

Special

setup

for

accessing

DB2

for

z/OS

servers

from

Java

programs

Followthese stepsif youplantowriteJDBC orSQLJapplicationsthataccessDB2 forz/OS databaseservers.

Procedure:

1. InstallDB2for z/OSstoredprocedures.

IfanyJDBCorSQLJapplicationswillconnecttoaDB2 forz/OSserver,a numberof storedproceduresneedtobeinstalledonthatservertosupport retrieval ofDB2cataloginformation,tracing,anderrormessageformatting.The storedproceduresare:

v SQLCOLPRIVILEGES

v SQLCOLUMNS

v SQLFOREIGNKEYS

v SQLGETTYPEINFO

(24)

v SQLPROCEDURECOLS v SQLPROCEDURES v SQLSPECIALCOLUMNS v SQLSTATISTICS v SQLTABLEPRIVILEGES v SQLTABLES v SQLUDTS v SQLCAMESSAGE

ThefollowingDB2forz/OSPTFsprovidethelatestversions ofthestored procedures:

Table4.PTFsforDB2forz/OSstoredprocedures

DB2forz/OS PTFnumbers

Version7 UQ72083,UQ93889

Version8 UQ93890

Askyour DB2forz/OSsystem administratorwhetherthese storedprocedures areinstalled.

2. CreateDB2forz/OS tables.

IfanyJDBCorSQLJapplicationswillconnecttoaDB2 forz/OSserver,the followingtablesneedtobeinstalledonthatservertosupportefficientstoring ofdatainCLOBorDBCLOBcolumns:

v SYSIBM.SYSDUMMYU

v SYSIBM.SYSDUMMYA

v SYSIBM.SYSDUMMYE

JobsthatdefinethetablesareshippedinthefollowingPTFs:

Table5.PTFsforDB2forz/OS

DB2forz/OSVersion PTFnumber

Version7 UQ86843

Version8 UQ86844

Askyour DB2forz/OSsystem administratorwhetherthese tablesaredefined. 3. EnableUnicodesupportforOS/390 andz/OSservers.

IfanySQLJorJDBC programswilluseIBMDB2Driver forJDBCandSQLJ type 4connectivitytoconnecttoa DB2forz/OSVersion7server,theOS/390 orz/OSoperatingsystem mustsupporttheUnicodeUTF-8encodingscheme. ThissupportrequiresOS/390Version2Release9withAPAROW44581,ora laterreleaseofOS/390 orz/OS,plustheOS/390R8/R9/R10Supportfor Unicode.InformationAPARsII13048andII13049containadditional information.

DB2T4XAIndoubtUtil

for

distributed

transactions

with

DB2

UDB

for

OS/390

and

z/OS

Version

7

servers

IfyouplantoimplementdistributedtransactionsusingIBMDB2Driver forJDBC and SQLJtype4connectivity thatincludeDB2UDBfor OS/390andz/OSVersion 7 servers,youneed toruntheDB2T4XAIndoubtUtilutilityagainstthoseservers. ThisutilityallowsVersion7 servers,whichdonothavebuilt-insupport for distributed transactionsthatimplementtheXAspecification,toemulatethat support.

(25)

v Createsatable namedSYSIBM.INDOUBTandanassociatedindex

v BindsDB2packagesnamedT4XAIN01,T4XAIN02, T4XAIN03,and T4XAIN04

YoushouldcreateanddroppackagesT4XAIN01,T4XAIN02, T4XAIN03,and T4XAIN04onlybyrunningDB2T4XAIndoubtUtil.Youcancreateanddrop SYSTEM.INDOUBTanditsindexmanually,butitisrecommended thatyouuse theutility.See “DB2T4XAIndoubtUtilusagenotes”onpage18forinstructionson how tocreatethoseobjectsmanually.

DB2T4XAIndoubtUtil authorization:

ToruntheDB2T4XAIndoubtUtilutilitytocreateSYSTEM.INDOUBTand bind packagesT4XAIN01, T4XAIN02,T4XAIN03, andT4XAIN04,youneedSYSADM authority.

ToruntheDB2T4XAIndoubtUtilonlytobind packagesT4XAIN01, T4XAIN02, T4XAIN03, andT4XAIN04, youneedBIND authorityonthepackages.

DB2T4XAIndoubtUtil syntax:

 java com.ibm.db2.jcc.DB2T4XAIndoubtUtil -url jdbc:db2: //server /database :port



 -user user-ID -password password

-owner owner-ID -help -delete -bindonly

  -showSQL -jdbcCollection NULLID -jdbcCollection collection-ID 

DB2T4XAIndoubtUtil parameterdescriptions: -url

SpecifiesthedatasourceatwhichDB2T4XAIndoubtUtilistorun.Thevariable partsofthe-urlvalueare:

jdbc:db2:

IndicatesthattheconnectionistoaserverintheDB2family.

server

ThedomainnameorIPaddressofthedatabaseserver.

port

TheTCP/IPserverportnumberthatisassignedtothedatabase server. Thisisanintegerbetween0 and65535.Thedefaultis446.

database

Anameforthedatabase server.

databaseistheDB2locationnamethatisdefinedduring installation.All charactersin thisvaluemust beuppercase characters.Youcandetermine thelocationnamebyexecutingthefollowingSQLstatementontheserver:

SELECT CURRENT SERVER FROM SYSIBM.SYSDUMMY1; -user

SpecifestheuserIDunderwhichDB2T4XAIndoubtUtilistorun.Thisuser must haveSYSADMauthorityormust bea memberofaRACF®groupthat corresponds toasecondaryauthorizationIDwith SYSADMauthority.

(26)

-password

SpecifesthepasswordfortheuserID.

-owner

Specifiesa secondaryauthorizationIDthathasSYSADMauthority.Usethe -owner parameterifthe-userparameter valuedoesnothaveSYSADM authority.The-user parametervaluemust bea memberofaRACFgroup whosenameisowner-ID.

Whenthe-ownerparameterisspecified,DB2T4XAIndoubtUtilusesowner-ID

as:

v TheauthorizationIDforcreatingtheSYSIBM.INDOUBTtable.

v TheauthorizationIDoftheowneroftheT4XAIN01,T4XAIN02, T4XAIN03,

andT4XAIN04packages.SQLstatementsinthose packagesare executed usingtheauthorityofowner-ID.

-help

SpecifiesthattheDB2T4XAIndoubtUtilutilitydescribeseachof theoptions thatit supports.Ifanyotheroptionsarespecifiedwith -help,theyareignored.

-delete

SpecifiesthattheDB2T4XAIndoubtUtilutilitydeletestheobjectsthatwere created whenDB2T4XAIndoubtUtilwasrunpreviously.

-bindonly

SpecifiesthattheDB2T4XAIndoubtUtilutilitybindstheT4XAIN01,T4XAIN02, T4XAIN03, andT4XAIN04packagesandgrantspermissiontoPUBLICto executethepackages,but doesnotcreatetheSYSIBM.INDOUBTtable.

-showSQL

SpecifiesthattheDB2T4XAIndoubtUtilutilitydisplaystheSQLstatementsthat it executes.

-jdbcCollection collection-name|NULLID

Specifiesthevalueof the-collection parameterthatwasusedwhentheIBM DB2 DriverforJDBCand SQLJpackageswere boundwiththeDB2Binder utility. The-jdbcCollectionparametermustbespecifiediftheexplicitlyor implicitlyspecifiedvalue ofthe-collectionparameterwas notNULLID. Thedefaultis-jdbcCollectionNULLID.

DB2T4XAIndoubtUtil usagenotes:

TocreatetheSYSTEM.INDOUBTtableanditsindexmanually,usethese SQL statements:

CREATE TABLESPACE INDBTTS USING STOGROUP LOCKSIZE ROW BUFFERPOOL BP0 SEGSIZE 32 CCSID EBCDIC;

CREATE TABLE SYSIBM.INDOUBT(indbtXid VARCHAR(140) FOR BIT DATA NOT NULL, uowId VARCHAR(25) FOR BIT DATA NOT NULL, pSyncLog VARCHAR(150) FOR BIT DATA, cSyncLog VARCHAR(150) FOR BIT DATA) IN INDBTTS;

CREATE UNIQUE INDEX INDBTIDX ON SYSIBM.INDOUBT(indbtXid, uowId); DB2T4XAIndoubtUtil example:

(27)

RuntheDB2T4XAIndoubtUtiltoallowaDB2forOS/390 andz/OSVersion7 subsystemthathasIPaddressmvs1,portnumber446,and DB2locationname SJCEC1toparticipateinXAdistributed transactions.

java com.ibm.db2.jcc.DB2T4XAIndoubtUtil -url jdbc:db2://mvs1:446/SJCEC1 \ -user SYSADM -password mypass

Related tasks:

v “InstallingtheIBM DB2DriverforJDBC andSQLJ”onpage4

Special

setup

for

running

Java

routines

in

the

HP-UX

environment

For theHP-UXoperatingsystemonPA-RISCprocessors,youhaveextra prerequisites forrunningJavastoredproceduresand user-definedfunctions.In additiontotheprerequisitesin“InstallingtheIBMDB2Driver forJDBCandSQLJ” onpage4,youneedtoperformthefollowingprerequisitesteps:

1. Enablethedb2hpjvtoolbyissuingthefollowingcommandsonthecommand

line:

db2hpjv -e db2stop db2start

Ifyouneedtodisabledb2hpjv,issuethesecommands:

db2hpjv -d db2stop db2start

Java mustbe installedontheoperatingsystembefore youissuedb2hpjv -e. DB2DatabaseforLinux,UNIX,andWindowscannotrunonHP-UXif Java routinesupportisenabled,butJava isnotontheoperatingsystem.

2. Give theHP-UXrun-timelinkeraccesstoJavashared libraries.

TorunJavastoredproceduresoruser-definedfunctions,theHP-UX run-time linkermustbe abletoaccesscertainJavashared libraries,andtheDB2system must beabletoloadthese librariesandtheJVM.Becausetheprogramthat doesthisloadingrunswithsetuidprivileges,itlooks forthedependent

librariesonlyin/usr/lib/pa20_64.TocreateaccesstotheJavashared libraries, chooseoneofthefollowingmethods:

v CreatesymboliclinkstotheJavashared libraries.Todo that,loginasroot,

and issuethefollowingcommandstocreatesymboliclinkstotheJava shared libraries:

ln -s /opt/java1.4/jre/lib/PA_RISC2.0W/*.sl /usr/lib/pa20_64

ln -s /opt/java1.4/jre/lib/PA_RISC2.0W/hotspot/*.sl /usr/lib/pa20_64

Thesecommandscreatesymboliclinksto thefollowinglibraries:

/opt/java1.4/jre/lib/PA_RISC2.0W/libnet.sl /opt/java1.4/jre/lib/PA_RISC2.0W/libzip.sl /opt/java1.4/jre/lib/PA_RISC2.0W/librmi.sl /opt/java1.4/jre/lib/PA_RISC2.0W/libnio.sl /opt/java1.4/jre/lib/PA_RISC2.0W/libverify.sl /opt/java1.4/jre/lib/PA_RISC2.0W/libmlib_image.sl /opt/java1.4/jre/lib/PA_RISC2.0W/libhprof.sl /opt/java1.4/jre/lib/PA_RISC2.0W/libjaas_unix.sl /opt/java1.4/jre/lib/PA_RISC2.0W/libawt.sl /opt/java1.4/jre/lib/PA_RISC2.0W/libcmm.sl /opt/java1.4/jre/lib/PA_RISC2.0W/libdcpr.sl /opt/java1.4/jre/lib/PA_RISC2.0W/libdt_socket.sl

(28)

/opt/java1.4/jre/lib/PA_RISC2.0W/libfontmanager.sl /opt/java1.4/jre/lib/PA_RISC2.0W/libioser12.sl /opt/java1.4/jre/lib/PA_RISC2.0W/libmawt.sl /opt/java1.4/jre/lib/PA_RISC2.0W/libjsound.sl /opt/java1.4/jre/lib/PA_RISC2.0W/libjava.sl /opt/java1.4/jre/lib/PA_RISC2.0W/libjawt.sl /opt/java1.4/jre/lib/PA_RISC2.0W/libjcov.sl /opt/java1.4/jre/lib/PA_RISC2.0W/libjcpm.sl /opt/java1.4/jre/lib/PA_RISC2.0W/libjdwp.sl /opt/java1.4/jre/lib/PA_RISC2.0W/libjpeg.sl /opt/java1.4/jre/lib/PA_RISC2.0W/hotspot/libjsig.sl /opt/java1.4/jre/lib/PA_RISC2.0W/hotspot/libjvm.sl

v Addthe/opt/java1.4/jre/lib/PA_RISC2.0Wand opt/java1.4/jre/lib/

PA_RISC2.0W/hotspot directoriestothe/etc/dld.sl.conffile,andtothe SHLIB_PATHenvironment.

IftheDB2servercannotfindthesharedJava librarieswhenitexecutesa Java routine,itgeneratesa -4300error.

Related concepts:

v “Javasampleprograms”inSamplesTopics

v “Javaappletconsiderations”onpage163

v “TheDB2database applicationdevelopmentenvironment”inGettingStartedwith DatabaseApplicationDevelopment

Related tasks:

(29)

Chapter

2.

Programming

JDBC

applications

Thetopics thatfollowcontaininformationaboutwritingJDBCapplications. v “BasicstepsinwritingaJDBC application”

v “Connectingtodatabase serversinJDBCapplications” onpage24

v “JavapackagesforJDBC support”onpage35

v “LearningaboutadatasourceusingDatabaseMetaDatamethods”onpage35

v “VariablesinJDBCapplications”onpage37

v “ExecutingSQLstatementsinJDBC applications”onpage38

v “Workingwith XMLdatainJDBCapplications”onpage68

v “TransactioncontrolinJDBC applications”onpage76

v “HandlingerrorsandwarningsinJDBC applications”onpage77

v “IBMDB2 DriverforJDBCand SQLJclient reroutesupport”onpage86

v “DisconnectingfromdatabaseserversinJDBC applications”onpage88

Basic

steps

in

writing

a

JDBC

application

Writing aJDBC applicationhasmuchincommonwith writinganSQLapplication inanyotherlanguage:Ingeneral,youneed todothefollowingthings:

v AccesstheJava packagesthatcontainJDBCmethods.

v Declarevariablesfor sendingdatatoorretrievingdatafromDB2tables.

v Connectto adatasource.

v ExecuteSQLstatements.

v HandleSQLerrorsand warnings.

v Disconnectfromthedatasource.

Althoughthetasksthatyouneedtoperformare similartothoseinother languages,thewaythatyouexecutethosetasksissomewhatdifferent.

Figure1onpage22isasimple programthatdemonstrates eachtask.Thisprogram runsontheIBMDB2Driver forJDBCandSQLJ.

(30)

import java.sql.*; 1

public class EzJava {

public static void main(String[] args) { String urlPrefix = "jdbc:db2:"; String url; String empNo; 2 Connectioncon; Statementstmt; ResultSetrs;

System.out.println ("**** Enter class EzJava");

// Check the that first argument has the correct form for the portion // of the URL that follows jdbc:db2:, as described

// in the Connecting to a data source using the DriverManager // interfacewith the IBM DB2 Driver for JDBC and SQLJ topic.

// For example, for IBM DB2 Driver for JDBC and SQLJ type 2 connectivity, // args[0] might be MVS1DB2M. For

// type 4 connectivity, args[0] might // be //stlmvs1:10110/MVS1DB2M. if (args.length==0)

{

System.err.println ("Invalid value. First argument appended to "+ "jdbc:db2: must specify a valid URL.");

System.exit(1); }

url = urlPrefix + args[0];

try {

// Load the IBM DB2 Driver for JDBC and SQLJ

Class.forName("com.ibm.db2.jcc.DB2Driver"); 3a System.out.println("**** Loaded the JDBC driver");

// Create the connectionusing the IBM DB2 Driver for JDBC and SQLJ con = DriverManager.getConnection (url); 3b // Commit changes manually

con.setAutoCommit(false);

System.out.println("**** Created a JDBC connection to the data source");

// Create the Statement stmt = con.createStatement();

4a System.out.println("**** Created JDBC Statement object");

// Execute a query and generate a ResultSet instance

rs = stmt.executeQuery("SELECT EMPNO FROM EMPLOYEE"); 4b System.out.println("**** Created JDBC ResultSet object");

// Print all of the employee numbers to standard output device while (rs.next()) {

empNo = rs.getString(1);

System.out.println("Employee number = " + empNo); }

System.out.println("**** Fetched all rows from JDBC ResultSet");

(31)

Notes® toFigure1 onpage22:

Note Description

1 Thisstatementimportsthejava.sqlpackage,whichcontainstheJDBCcoreAPI. ForinformationonotherJavapackagesthatyoumightneedtoaccess,see AccessJavapackagesforJDBCsupport.

2 StringvariableempNoperformsthefunctionofahostvariable.Thatis,itis usedtoholddataretrievedfromanSQLquery.SeeDeclarevariablesinJDBC applicationsformoreinformation.

3aand 3b

Thesetwosetsofstatementsdemonstratehowtoconnecttoadatasourceusing oneoftwoavailableinterfaces.SeeConnecttoadatasourceusingJDBCfor moredetails.

4aand 4b

ThesetwosetsofstatementsdemonstratehowtoperformaSELECTinJDBC. ForinformationonhowtoperformotherSQLoperations,seeExecuteSQLina JDBCapplication.

5 Thistry/catchblockdemonstratestheuseoftheSQLExceptionclassforSQL errorhandling.FormoreinformationonhandlingSQLerrors,seeHandlean SQLExceptionundertheIBMDB2DriverforJDBCandSQLJ.Forinformation onhandlingSQLwarnings,seeHandleSQLwarningsinaJDBCapplication. 6 Thisstatementdisconnectstheapplicationfromthedatasource.SeeClosethe

connectiontothedatasource.

Related concepts:

v “JavapackagesforJDBC support”onpage35 // Close the ResultSet

rs.close();

System.out.println("**** Closed JDBC ResultSet");

// Close the Statement stmt.close();

System.out.println("**** Closed JDBC Statement");

// Connection must be on a unit-of-work boundary to allow close con.commit();

System.out.println ( "**** Transaction committed" );

// Close the connection

con.close(); 6 System.out.println("**** Disconnected from data source");

System.out.println("**** JDBC Exit from class EzJava - no errors");

}

catch (ClassNotFoundException e) {

System.err.println("Couldnot load JDBC driver"); System.out.println("Exception: " + e); e.printStackTrace(); } catch(SQLException ex) 5 { System.err.println("SQLException information"); while(ex!=null) {

System.err.println ("Error msg: " + ex.getMessage()); System.err.println ("SQLSTATE: " + ex.getSQLState()); System.err.println ("Error code: " + ex.getErrorCode()); ex.printStackTrace();

ex = ex.getNextException(); // For drivers that support chained exceptions }

}

} // End main

} // End EzJava

(32)

v “HowJDBC applicationsconnecttoa datasource”onpage24

v “VariablesinJDBCapplications” onpage37

v “JDBCinterfacesforexecutingSQL”onpage38

Related tasks:

v “HandlinganSQLExceptionundertheIBMDB2 DriverforJDBCand SQLJ”on

page77

v “HandlinganSQLWarningundertheIBM DB2DriverforJDBCand SQLJ”on

page81

Connecting

to

database

servers

in

JDBC

applications

The followingtopics containinformationonconnection toDB2DatabaseforLinux, UNIX,and Windowsdatabaseservers.

How

JDBC

applications

connect

to

a

data

source

Before youcanexecuteSQLstatementsinanySQLprogram,youmustconnectto a databaseserver.InJDBC, adatabaseserverisknownasa datasource.

Figure2 showshowaJava applicationconnectstoa datasourceforatype 2driver or IBMDB2DriverforJDBC andSQLJtype2 connectivity.

Java application DriverManager or DataSource Local database or DB2 subsystem JDBC driver* Database server

*Java byte code executed under JVM, and native code

Figure2.Javaapplicationflowforatype2driverorIBMDB2DriverforJDBCandSQLJ type2connectivity

(33)

Figure3shows howaJava applicationconnectstoa datasourceforIBMDB2 Driver forJDBCandSQLJtype 4connectivity.

Related concepts:

v “HowDB2applicationsconnecttoa datasourceusingtheDriverManager

interfacewiththeDB2JDBC Type2Driver”onpage25

Related tasks:

v “Connectingtoa datasourceusingtheDataSourceinterface”onpage30

v “Connectingtoa datasourceusingtheDriverManagerinterfacewith theIBM

DB2DriverforJDBC andSQLJ”onpage27

How

DB2

applications

connect

to

a

data

source

using

the

DriverManager

interface

with

the

DB2

JDBC

Type

2

Driver

AJDBC applicationcanestablishaconnectiontoa datasourceusingtheJDBC DriverManager interface,whichispart ofthejava.sqlpackage.

TheJava applicationfirst loadstheJDBCdriverbyinvokingtheClass.forName method.Aftertheapplication loadsthedriver,it connectstoadatabase serverby invoking theDriverManager.getConnectionmethod.

For theDB2JDBCType2 DriverforLinux,UNIXandWindows (DB2JDBCType2 Driver), youloadthedriverbyinvoking theClass.forNamemethodwiththe followingargument:

COM.ibm.db2.jdbc.app.DB2Driver

Thefollowingcodedemonstrates loadingtheDB2JDBC Type2Driver:

Java application DriverManager or DataSource JDBC driver* Database server

*Java byte code executed under JVM DRDA

References

Related documents

Comparatively lower pupal weights were recorded in larvae reared on fresh leaves/pods and on artificial diets with leaf and pod powder of ICC 12476, ICC 12477, ICC 12478, and ICC

Magnetostrictive sensor, data sheet model BLM Magnetic switches Magnetic switch, data sheet model BGU Approvals Ex c, GL, DNV Ex c, GL, DNV - Bypass level indicator, special

jurisdictions will not permit a unilateral amendment of the terms and conditions of employment once the initial employment relationship has been established, it is imperative that the

An evaluation framework is needed to determine the impact of affordable Aboriginal housing on social, cultural, economic, and health indicators among tenants of the M’akola

Our focus is not on the wider contribution of the humanities and social sciences to the study of mental (ill) health and clinical practice; more narrowly, we seek to show how work

- Samples collect from the subject 616 at two different time points – exacerbation (Exac) and 6 weeks post exacerbation at clinically recover (Recovery) - taxonomic composition

Technology, 2003) region of interest with b) its Laplacian pyramid representation at level 2, and c) three internal image seams overlaid. For clarity, the horizontal internal