Thefollowingtopics containinformationabouttheJava sampleapplicationsthat are providedwithDB2DatabaseforLinux,UNIX,andWindows.
v “JDBCsamples”
v “SQLJsamples”onpage174
v “Javaplug-insamples” onpage178
v “JavaWebSpheresamples”onpage179
JDBC
samples
UNIX directory:sqllib/samples/java/jdbc.
Windows directory:sqllib\samples\java\jdbc.
JDBC samplesincludethefollowingtypesofprograms:
ADMIN_CMDroutinesamples
Samples thatdemonstratetheuseofADMIN_CMDstored procedurefor administrationtasks viaSQLinterface
Installation-image-levelsamples
Programsthatdealwith theinstallationimagelevelofthedatabase product.
Database-level samples
Programsthatdealwith databaseobjects.
Table-levelsamples
Programsthatdealwith tableobjects.
Data typesamples
Programsthatdealwith datatypes.
Applet samples
Samples thatdemonstrateJavaapplets.
Storedproceduresamples
Samples thatdemonstratestoredprocedures.
User-definedfunctionsamples
Samples thatdemonstrateuser-definedfunctions.
Java beansamples
Samples thatdemonstrateJavabeanclasses.
Java GSS-APIPluginsamples
Samples thatdemonstratetheJCC GCC_APIplugin
Othersamples
Table22.JDBCsampleprogramfiles
Typeofsample Sampleprogramname ProgramDescription
ADMIN_CMD stored
procedure samples
AdmCmdAutoCfg.java Howtoautoconfigureadatabaseusing ADMIN_CMDroutine.
AdmCmdContacts.java Howtoadd,updateanddropcontacts andcontactgroupsusing
ADMIN_CMDroutine.
AdmCmdOnlineBackup.java Howtoperformonlinebackupusing ADMIN_CMDroutine.
AdmCmdUpdateCfg.java HowtoupdateandresettheDatabase andDatabaseManagerconfiguration parametersusingADMIN_CMD routine.
AdmCmdExport.java Howtoexportdatausing
ADMIN_CMDroutine.
AdmCmdImport.java Howtoimportdatausing
ADMIN_CMDroutine. AdmCmdQuiesce.java Howtoquiescetablespaceand
databaseusingADMIN_CMDroutine. AdmCmdDescribe.java Howtodescribetableandindices
usingADMIN_CMDroutine. Installation-
image-level samples
IlInfo.java Howtogetandsetinstallationlevel
Table22.JDBCsampleprogramfiles (continued)
Typeofsample Sampleprogramname ProgramDescription
Database-level samples
DbAuth.java Howtogrant/display/revoke
authoritiesatthedatabaselevel.
DbConn.java Howtoconnectanddisconnectfroma
database.
DbInfo.java Howtogetandsetinformationata
databaselevel.
DbMCon.java Howtoconnectanddisconnectfrom
multipledatabases.
DbNative.java Howtotranslateastatementthat
containsanODBCescapeclausetoa datasourcespecificformat.
DbRsHold.java Howtouseresultsetcursor
holdabilityintheDB2JDBCType2 DriverforLinux,UNIXandWindows andtheIBMDB2DriverforJDBCand SQLJ.Tocompilethissample,you needJavaDeveloperKit1.4orabove. Torunthissample,youneedJava RuntimeEnvironment1.4orabove.
DbSeq.java Howtocreate,alteranddropa
sequenceinadatabase.
DbUse.java Howtousedatabaseobjects.
GetDBCfgParams.java Howtogetdatabaseconfiguration parameters.
GetDBMCfgParams.java Howtogetdatabasemanager configurationparameters.
GetLogs.java Howtogetcustomerviewof
Table22.JDBCsampleprogramfiles (continued)
Typeofsample Sampleprogramname ProgramDescription
Table-level samples
GetMessage.java Howtogeterrormessageinthe requiredlocalewithtoken replacement.
LargeRid.java HowtoenableLargeRIDssupporton
bothnewtables/tablespacesand existingtables/tablespaces.
SetIntegrity.java HowtoperformonlineSET
INTEGRITYonatable.
TbAST.java Howtousestagingtableforupdating
deferredAST.
TbCompress.java Howtocreatetableswithnulland defaultvaluecompressionoption.
TbConstr.java Howtoworkwithtableconstraints.
TbCreate.java Howtocreate,alteranddroptables.
TbGenCol.java Howtousegeneratedcolumns.
TbIdent.java HowtouseIdentityColumns.
TbInfo.java Howtogetandsetinformationata
tablelevel.
TbInTrig.java Howtousean’INSTEADOF’trigger
onaview.
TbMerge.java HowtousetheMERGEstatement.
TbMod.java Howtomodifyinformationinatable.
TbOnlineInx.java Howtocreateandreorgindexesona table.
TbPriv.java Howtogrant/display/revoketable
levelprivileges.
TbRead.java Howtoreadinformationinatable.
TbRowcompress.java Howtoperformrowcompressionona table
TbSel.java Howtoselectfromeachof:insert,
update,delete.
TbTemp.java HowtouseDeclaredTemporary
Tables.
TbTrig.java Howtouseatriggeronatable.
TbUMQT.java Howtouseusermaterialzedquery
tables(summarytables).
TbUnion.java HowtoinsertthroughaUNIONALL
view.
Datatypes DtInfo.java Howtogetinformationaboutdata
types.
DtLob.java HowtoreadandwriteLOBdata.
DtUdt.java Howtocreate,use,anddrop
user-defineddistincttypes.
Table22.JDBCsampleprogramfiles (continued)
Typeofsample Sampleprogramname ProgramDescription
Stored procedure samples
spcat Storedprocedurecatalogscriptforthe
spserverprogram.Thisscriptcalls SpDrop.db2andSpCreate.db2.
SpCreate.db2 CLPscripttoissueCREATE
PROCEDUREstatements.
SpDrop.db2 CLPscripttodropstoredprocedures
fromthecatalog.
SpClient.java Clientprogramusedtocalltheserver functionsdeclaredinSpServer.java.
SpServer.java Storedprocedurefunctionsbuiltand
runontheserver. User-defined
function samples
UDFcli.java Clientapplicationwhichcallsthe
user-definedfunctionlibraryUDFsrv.
UDFsrv.java User-definedfunctionscalledby
UDFcli.java.
udfcat UDFcatalogscriptfortheUDFsrv
program.Thisscriptcalls
UDFDrop.db2andUDFCreate.db2.
UDFDrop.db2 CLPscripttodropUDFsfromthe
catalog.
UDFCreate.db2 CLPscripttoissueCREATE
PROCEDUREstatements.
UDFjcli.java Clientapplicationwhichcallsthe
user-definedfunctionlibraryUDFjsrv.
UDFjsrv.java User-definedfunctionscalledby
UDFjcli.java.
udfjcat UDFcatalogscriptfortheUDFjsrv
program.Thisscriptcalls
UDFjDrop.db2andUDFjCreate.db2.
UDFjDrop.db2 CLPscripttodropUDFsfromthe
catalog.
UDFjCreate.db2 CLPscripttoissueCREATE
PROCEDUREstatements.
UDFsCreate.db2 HowtocatalogtheUDFscontainedin
UDFsqlsv.java
UDFsDrop.db2 HowtouncatalogtheUDFscontained
inUDFsqlsv.java
UDFsqlcl.java CalltheUDFsinUDFsqlsv.java
UDFsqlsv.java User-DefinedFunctionswithSQL
statementscalledbyUDFsqlcl.java Javabean
samples
CreateEmployee.java Howtocreateanemployeerecord. GeneratePayroll.java Howtogeneratepayrollreportsby
Table22.JDBCsampleprogramfiles (continued)
Typeofsample Sampleprogramname ProgramDescription
JavaGSS-API Pluginsamples
JCCKerberosPlugin.java ImplementaGSS-APIPluginthatdoes KerberosauthenticationusingIBM DB2UniversalDriver.
JCCKerberosPluginTest.java UseJCCKerberosPlugintogetaDB2 ConnectionusingIBMDB2Universal Driver.
JCCSimpleGSSPlugin.java ImplementaGSS-APIPluginthatdoes useridandpasswordcheckingusing IBMDB2UniversalDriver.
JCCSimpleGSSContext.java ImplementaGSSContexttobeusedby JCCSimpleGSSPlugin
JCCSimpleGSSCredential.java ImplementaGSSCredentialtobeused byJCCSimpleGSSPlugin
JCCSimpleGSSException.java ImplementaGSSExceptiontobeused byJCCSimpleGSSPlugin
JCCSimpleGSSName.java ImplementaGSSNametobeusedby JCCSimpleGSSPlugin
JCCSimpleGSSPluginTest.java UseJCCSimpleGSSPlugintogetaDB2 ConnectionusingIBMDB2Universal Driver.
Othersamples Util.java UtilitiesforJDBCsampleprograms.
Related concepts:
v “Javasampleprograms”inSamplesTopics
v “Samplefiles”inSamplesTopics
Related reference:
v “Javaplug-insamples” onpage178
v “JavaWebSpheresamples”onpage179
v “SQLJsamples”onpage174
SQLJ
samples
UNIX directory:sqllib/samples/java/sqlj.
Windows directory:sqllib\samples\java\sqlj.
SQLJsamplesincludethefollowingtypesofprograms:
Database-level samples
Programsthatdeal withdatabaseobjects.
Table-levelsamples
Programsthatdeal withtableobjects.
Data typesamples
Programsthatdeal withdatatypes.
Applet samples
Storedproceduresamples
Samples thatdemonstratestoredprocedures.
User-definedfunctionsamples
Samples thatdemonstrateuser-definedfunctions.
Java beansamples
Samples thatdemonstrateJavabeanclasses.
Data sourcesamples
Samples thatdemonstratedatasources.
Othersamples
Samples thatdonotfallintoanyof thepreviouscategories.
Table23.SQLJsampleprogramfiles
Typeof
sample Sampleprogramname ProgramDescription
Database-level sample
DbAuth.sqlj Howtogrant/display/revokeauthorities
atthedatabaselevel.
DbConn.sqlj Howtoconnectanddisconnectfroma
database.
DbMCon.sqlj Howtoconnectanddisconnectfrom
multipledatabases.
Table23.SQLJsampleprogramfiles (continued)
Typeof
sample Sampleprogramname ProgramDescription
Table-level sample
LargeRid.sqlj HowtoenableLargeRIDssupporton
bothnewtables/tablespacesand existingtables/tablespaces.
SetIntegrity.sqlj HowtoperformonlineSETINTEGRITY onatable.
TbAST.sqlj Howtousestagingtableforupdating
deferredAST.
TbCompress.sqlj Howtocreatetableswithnulland defaultvaluecompressionoption. TbConstr.sqlj Howtoworkwithtableconstraints. TbCreate.sqlj Howtocreate,alteranddroptables.
TbIdent.sqlj Howtouseidentitycolumns.
TbInfo.sqlj Howtogetandsetinformationatatable level.
TbMod.sqlj Howtomodifyinformationinatable.
TbOnlineInx.sqlj Howtocreateandreorgindexesona table.
TbPriv.sqlj Howtogrant/display/revoketablelevel
privileges.
TbRowcompress.sqlj Howtoperformrowcompressionona table
TbRunstats.sqlj Howtoperformrunstatsonatable.
TbRead.sqlj Howtoreadinformationinatable.
TbSel.sqlj Howtoselectfromeachof:insert,
update,delete.
TbTrig.sqlj Howtouseatriggeronatable.
TbUMQT.sqlj Howtouseusermaterialzedquery
tables(summarytables). Datatype
sample
DtUdt.sqlj Howtocreate,use,anddrop
user-defineddistincttypes.
Appletsample Applt.sqlj Howtouseapplets.
Stored procedure sample
spcat Storedprocedurecatalogscriptforthe
SpServerprogram.Thisscriptcalls SpDrop.db2andSpCreate.db2.
SpCreate.db2 CLPscripttoissueCREATE
PROCEDUREstatements.
SpDrop.db2 CLPscripttodropstoredprocedures
fromthecatalog.
SpClient.sqlj Clientprogramusedtocalltheserver functionsdeclaredinSpServer.sqlj. SpServer.sqlj Storedprocedurefunctionsbuiltandrun
ontheserver.
Table23.SQLJsampleprogramfiles (continued)
Typeof
sample Sampleprogramname ProgramDescription
User-defined function sample
UDFcli.sqlj Clientapplicationwhichcallsthe
user-definedfunctionlibraryUDFsrv. UDFsrv.java User-definedfunctionscalledbyUDFcli.
udfcat UDFcatalogscriptfortheUDFsrv
program.ThisscriptcallsUDFDrop.db2 andUDFCreate.db2.
UDFDrop.db2 CLPscripttodropUDFsfromthe
catalog.
UDFCreate.db2 CLPscripttoissueCREATE
PROCEDUREstatements. UDFjcli.sqlj Clientapplicationwhichcallsthe
user-definedfunctionlibraryUDFjsrv. UDFjsrv.java User-definedfunctionscalledbyUDFjcli.
udfjcat UDFcatalogscriptfortheUDFjsrv
program.ThisscriptcallsUDFjDrop.db2 andUDFjCreate.db2.
UDFjDrop.db2 CLPscripttodropUDFsfromthe
catalog.
UDFjCreate.db2 CLPscripttoissueCREATE
PROCEDUREstatements. Javabean
sample
CreateEmployee.sqlj Howtocreateanemployeerecord. GeneratePayroll.sqlj Howtogeneratepayrollreportsby
department. Datasource
sample
Batch1Demo.sqlj SQLJbatching--HowSQLJbatching works.
Batch2Demo.sqlj SQLJbatching-Associationof ExecutionContextwithBatchContext. Batch3Demo.sqlj SQLJBatching-Whendoweneedto
implicitlyexecuteabatch.
BlobClobDemo.sqlj HowtoaccessBloborClobfieldsinDB2 tables.
createRegisterDS.java CreateandRegisterDataSourcesas specifiedbytheDataSourceproperty files.
CreateDemoSchema.sqlj Thisprogramcreatestheschemaforthe DataSourceDemoprograms.
DbConnDataSource.sqlj Howtoconnecttoadatabaseusing DataSourcewiththeIBMDB2Driverfor JDBCandSQLJ.
DbConMDataSources.sqlj Howtoconnecttoadatabaseusing MultipleDataSourceswiththeIBMDB2 DriverforJDBCandSQLJ.
ScrollIterDemo.sqlj HowtouseNamedandPositional ScrollableIteratorsinSQLJ.
Related concepts:
v “Javasampleprograms”inSamplesTopics
v “Samplefiles”inSamplesTopics
Related reference:
v “Javaplug-insamples” onpage178
v “JavaWebSpheresamples”onpage179
v “JDBCsamples” onpage169
Java
plug-in
samples
UNIX directory:sqllib/samples/java/plugin.
Windows directory:sqllib\samples\java\plugin.
Table24.JavaControlCenterplug-insamplefiles
Sampleprogram
name Programdescription
Example1.java HowtoaddanewtoolbarbuttontotheControlCentertoolbar. Example2.java HowtoaddnewmenuactionstoControlCenterDatabaseobjects. Example3.java HowtoaddnewobjectsunderDatabaseobjectsintheControl
Centertree.
Example3Child.java Howtoaddplug-inobjectsunderDatabaseobjectsintheControl Centertree.
Example3Folder.java HowtoaddnewobjectsunderDatabaseobjectsintheControl Centertree.
Related concepts:
v “Compilingand runningtheexampleplugins”inAdministrationGuide: Implementation
v “Introducingtheplug-inarchitecturefor theControlCenter”inAdministration Guide:Implementation
v “WritingpluginsasControlCenterextensions”inAdministrationGuide: Implementation
v “Javasampleprograms”inSamplesTopics
v “Samplefiles”inSamplesTopics
Related tasks:
v “Creatinga pluginthatadds atoolbarbutton” inAdministrationGuide: Implementation
v “Settingattributesfor aplugintreeobject”inAdministrationGuide: Implementation
Related reference:
v “JavaWebSpheresamples”onpage179
v “JDBCsamples” onpage169
Java
WebSphere
samples
UNIX directory:sqllib/samples/java/Websphere.
Windows directory:sqllib\samples\java\Websphere.
Table25.JavaWebSpheresamplefiles
Sampleprogram
name Programdescription
AccessEmployee.ear ThisEnterpriseARchive(.EAR)fileconsistsoffourmodules containing32different.class,.JSPand.HTMLfiles.ThisEARfile, easilydeployedusingIBMWebSphereApplicationServer, demonstrateshowJavaclientscaninteractwithEnterpriseJava Beans(EJBs)toaccessdatastoredinDB2.
Related concepts:
v “Javasampleprograms”inSamplesTopics
v “Samplefiles”inSamplesTopics
Related reference:
v “Javaplug-insamples” onpage178
v “JDBCsamples” onpage169