-
Notifications
You must be signed in to change notification settings - Fork 85
/
README
431 lines (431 loc) · 18 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
******************************************************************************
* (c) Copyright IBM Corp. 2007 All rights reserved.
*
* The following sample of source code ("Sample") is owned by International
* Business Machines Corporation or one of its subsidiaries ("IBM") and is
* copyrighted and licensed, not sold. You may use, copy, modify, and
* distribute the Sample in any form without payment to IBM, for the purpose of
* assisting you in the development of your applications.
*
* The Sample code is provided to you on an "AS IS" basis, without warranty of
* any kind. IBM HEREBY EXPRESSLY DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR
* IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. Some jurisdictions do
* not allow for the exclusion or limitation of implied warranties, so the above
* limitations or exclusions may not apply to you. IBM shall not be liable for
* any damages you suffer as a result of using, copying, modifying or
* distributing the Sample, even if IBM has been advised of the possibility of
* such damages.
*
******************************************************************************
*
* README for JDBC Samples on Unix
*
* The <install_path>/sqllib/samples/java/jdbc directory contains this README
* file. Where <install_path> is the location of DB2 9.7 on your hard drive.
* The default location for <install_path> is
* $HOME
*
* This README describes how to build and run jdbc sample code for DB2 9.7.
* The DB2 9.7 jdbc samples are located in the following directory:
* <install_path>/sqllib/samples/java/jdbc
*
* Copy the files from this directory to your working directory prior to
* building the sample programs. The sample programs directory is
* typically read-only on most platforms and some samples produce output
* files that require write permissions on the directory.
*
* WARNING: Some of these samples may change your database or database
* manager configuration. Execute the samples against a test database
* only, such as the DB2 SAMPLE database.
*
******************************************************************************
*
* Prepare your DB2 sample development environment
*
* 1) Copy the files in <install_path>/sqllib/samples/java/jdbc/* to your
* working directory and ensure that directory has write permission.
*
* 2) Modify the CLASSPATH to include:
* <install_path>/sqllib/java/db2java.zip
* <install_path>/sqllib/java/db2jcc.jar
* <install_path>/sqllib/java/db2jcc_license_cu.jar
* <install_path>/sqllib/java/<jdkDirName>/lib
* <install_path>/sqllib/lib
* <install_path>/sqllib/function
* <install_path>/sqllib/java/sqlj.zip
* where <jdkDirName> is the name of the
* jdk directory under <install_path>/sqllib/java.
*
* Modify the PATH to include <install_path>/sqllib/java/<jdkDirName>/bin,
* <install_path>/sqllib/lib.
*
* Please make sure that JDK_PATH( db2
* database manager configuration parameter) is
* pointing to the <install_path>/sqllib/java/<jdkDirName>.
*
* To see the dbm cfg parameter value, run the following from db2
* command window and look for the value of JDK_PATH
* db2 get dbm cfg
*
* 3) Start the Database Manager with the following command:
* db2start
*
* 4) Create the sample database with the following command:
* db2sampl
*
* 5) Connect to the database with the following command:
* db2 connect to sample
*
* 6) To build Stored Procedures and User Defined Functions, ensure
* that you have write permission on the
* <install_path>/sqllib/function directory.
*
* 7) cd to the directory containing the files copied in step 1.
*
******************************************************************************
*
* Building DB2 Samples
*
* There are two ways to build DB2 samples: using a make utility or
* using javac compiler.
*
* o To build samples using the make utility see
* 'BUILDING SAMPLES USING make UTILITY'.
* o To build samples using the javac compiler or when you do not
* have a compatible make utility see 'BUILDING
* SAMPLES USING JAVAC COMPILER'.
*
******************************************************************************
*
* *** BUILDING SAMPLES USING make UTILITY ***
*
* If you have a compatible make utility on your system, you
* can use the makefile provided. Modify the PATH
* variable to include the directory containing the make
* utility.
*
* Depending on your environment, the makefile might have to be
* modified.For more details refer to the 'VARIABLES' section
* in the makefile.
*
* Execute the appropriate 'make' command in your working
* directory:
*
* o make <program name> - builds the sample identified by
* <program name>
* Do not include the file extension for the
* program name. E.g. make DbAuth
* For any dependencies refer to the individual sample.
*
* o make srv - builds only samples that can be run on the
* server,including routines (stored procedures and User
* Defined Functions).
*
* o make rtn - builds only routines.
*
* o make call_rtn - builds only client programs that call
* routines.
*
* o make client_run - builds only programs that run
* completely on the client (not ones that call routines).
*
* o make all_client - builds all client samples (all
* programs in the 'call_rtn' and 'client_run' categories).
*
* o make all - builds all supplied sample programs including
* routines, stored procedures and UDFs.
*
* After compiling the sample, run it using normal java
* invocation, java <program_name>
*
* Note:
* The makefile provided will only work if a compatible make
* executable program is resident on your system in a directory
* included in your PATH variable. Such a make utility may be
* provided by another language compiler.
*
******************************************************************************
*
* *** BUILDING SAMPLES USING JAVAC COMPILER ***
*
* As an alternative to the makefile, the javac compiler
* can be used to build the jdbc samples.
*
* If you do not have a compatible make utility you can use
* the javac bytecode compiler to build JDBC programs.
*
* Building and Executing Standalone Samples
* -----------------------------------------
*
* o Build the general utility class called Util.java.
* javac Util.java
*
* o Build the sample program
* javac <program name>.java
*
* o After compiling the sample, run it using normal java
* invocation
* java <program_name>
*
* Building and Executing Stored Procedures
* ----------------------------------------
*
* o Build the server file sample using:
* javac <Ser_prog_name>
* copy the resulting .class file
* to the sqllib/function directory.
*
* o Build jdbc store procedure using build file:
* spcat
*
* o Build the corresponding client file sample using:
* javac <Client_prog_name>.java
*
* o Run the client sample using normal java invocation:
* java <Client_prog_name>
*
* Building and Executing User Defined Functions:
* ----------------------------------------------
*
* o Build the server file sample using:
* javac <Ser_prog_name>
* copy the resulting .class file
* to the sqllib/function directory.
*
* o Build the User Defined Functions using build files:
* udfcat or udfjcat
*
* o Build the corresponding client file sample using:
* javac <Client_prog_name>.java
*
* o Run the client sample using normal java invocation:
* java <Client_prog_name>
*
******************************************************************************
*
* Common file Descriptions
*
* The following are the common files for JDBC samples. For more
* information on these files, refer to the program source files.
*
******************************************************************************
*
* Common files
*
* README - this file!
* makefile - Makefile for all files
* Util.java - utilities used by most programs
*
******************************************************************************
*
* JDBC Samples Design
*
* The JDBC sample programs form an object-based design reflecting the
* component nature of DB2. Related samples demonstrate a specific level
* of database programming. Each level is identified by the first two
* characters of the sample name. Here are the database levels
* represented by the samples:
*
* Identifier DB2 Level
*
* Ap Applet Level.
* Il Installation Image Level.
* Db Database Level.
* Tb Table Level.
* Dt Data Type Level.
* Ud UDF Level.
* Sp Stored Procedure Level.
*
* Also, there are tutorial samples that demonstrate how to implement
* Java GSS-API Plugin and how to use the plugin to get a DB2 connection
* using IBM DB2 Universal Driver (JCC driver). These programs begin
* with "JCC".
*
******************************************************************************
*
* JDBC Sample Descriptions
*
* The following are the JDBC sample files included with DB2. For more
* information on the sample programs, refer to the program source
* files.
*
******************************************************************************
*
* Applet Level
*
* Applt.html - HTML file for Applt.java
* Applt.java - How to create applets
*
******************************************************************************
*
* Installation Image Level
*
* IlInfo.java - How to get and set installation level information.
*
******************************************************************************
*
* ADMIN_CMD stored procedure samples (program files that deal with
* using SQL ADMIN_CMD() Stored Procedures)
*
* AdmCmdAutoCfg.java - How to autoconfigure a database
* AdmCmdContacts.java - How to add, update and drop contacts and
* contactgroups
* AdmCmdDescribe.java - How to describe table and indexes
* AdmCmdExport.java - How to export data
* AdmCmdImport.java - How to import data
* AdmCmdOnlineBackup.java - How to perform online backup
* AdmCmdQuiesce.java - How to quiesce tablespaces and database
* AdmCmdUpdateCfg.java - How to update, reset Database and Database
* Manager Configuration Parameters
******************************************************************************
*
* Database Level
*
* DbAuth.java - How to grant/display/revoke authorities at
* database level.
* DbConn.java - How to connect and disconnect from a database.
* DbInfo.java - How to get and set information at a database
* level.
* DbMCon.java - How to connect and disconnect from multiple
* databases.
* DbNative.java - How to translate a statement that contains an
* ODBC escape clause to a data source specific
* format.
* DbRsHold.java - How to use result set cursor holdability
* DbSeq.java - How to create, alter and drop a sequence in a
* database.
* DbUse.java - How to work with database objects.
* GetDBCfgParams.java - How to get DB CFG Parameters.
* GetDBMCfgParams.java - How to get DBM CFG Parameters.
* GetLogs.java - How to get customer view of diagnostic log
* file entries.
* TrustedContext.java - How to establish an explicit trusted connection and
* switching of the user.
*
******************************************************************************
*
* Table Level
*
* GetMessage.java - How to get error message in the required locale
* with token replacement.
* ImplicitCasting.java- To demonstrate use of implicit casting.
* LargeRid.java - How to enable Large RIDs support on both new
* tables/tablespaces and existing
* tables/tablespaces.
* SetIntegrity.java - How to perform online SET INTEGRITY on a table.
* ScalarFunctions.java- How to use scalar functions and special register.
* TbAST.java - How to use staging table for updating deferred
* AST.
* TbCompress.java - How to create tables with null and default
* value compression option.
* TbConstr.java - How to work with table constraints.
* TbCreate.java - How to create, alter, and drop tables.
* TbGenCol.java - How to use generated columns.
* TbIdent.java - How to use identity columns.
* TbMerge.java - How to use the MERGE statement.
* TbInfo.java - How to get and set information at a table
* level.
* TbInTrig.java - How to use INSTEAD OF triggers.
* TbMod.java - How to modify information in a table.
* TbOnlineInx.java - How to create and reorg indexes on a table.
* TbPriv.java - How to grant/display/revoke privileges at a
* table level.
* TbRead.java - How to read information in a table.
* TbRowcompress.java - To demonstrate row compression and automatic
* dictionary creation on a table
* TbRunstats.java - How to perform runstats on a table.
* TbSel.java - How to select from each of: insert, update,
* delete.
* TbTemp.java - How to use Declared Temporary Table.
* TbTrig.java - How to use a trigger on a table.
* TbUMQT.java - How to use user materialzed query tables
* (summary tables).
* TbUnion.java - How to insert through a UNION ALL view.
* Temporal.java - How to create Temporal Table and to add,
* modify and query data.
*
******************************************************************************
*
* Data Type Level
*
* DtInfo.java - How to get information on data types.
* DtLob.java - How to read and write LOB data.
* DtUdt.java - How to create/use/drop user defined distinct types.
*
******************************************************************************
*
* UDF Level
*
* UDFcli.java - Call the UDFs in UDFsrv.java.
* UDFCreate.db2 - CLP script to catalog the Java UDFs contained in
* UDFsrv.java.
* UDFDrop.db2 - CLP script to uncatalog the Java UDFs contained in
* UDFsrv.java.
* UDFjcli.java - Call the UDFs in UDFjsrv.java.
* UDFjCreate.db2 - CLP script to catalog the Java UDFs contained in
* UDFjsrv.java.
* UDFjDrop.db2 - CLP script to uncatalog the Java UDFs contained in
* UDFjsrv.java.
* UDFjsrv.java - Provide UDFs to be called by UDFjcli.java.
* UDFsCreate.db2 - CLP script to catalog the Java UDFs contained in
* UDFsqlsv.java.
* UDFsDrop.db2 - CLP script to uncatalog the Java UDFs contained in
* UDFsqlsv.java.
* UDFsqlcl.java - Call the UDFs in UDFsqlsv.java.
* UDFsqlsv.java - Provide UDFs to be called by UDFsqlcl.java.
* UDFsrv.java - Provide UDFs to be called by UDFcli.java.
*
******************************************************************************
*
* Stored Procedure Level
*
* SpCreate.db2 - CLP script to issue CREATE PROCEDURE statements.
* SpDrop.db2 - CLP script to drop stored procedures from the
* catalog.
* SpClient.java - Client application that calls the stored procedures.
* SpServer.java - Stored procedure functions built and run on the
* server.
* bonus_calculate.db2 - CLP script to issue CREATE PROCEDURE for
* Arrays_Sqlpl.java.
* stack_functions.db2 - CLP script to issue CREATE PROCEDURE for
* Array_Stack.java sample.
* Arrays_Sqlpl.java - Client application that calls the SQL stored
* procedure created in bonus_calculate.db2.
* Array_Stack.java - Client application that calls the SQL stored
* procedure created in stack_functions.db2.
*
******************************************************************************
*
* Java Beans Samples
*
* CreateEmployee.java - How to create an employee record.
* GeneratePayroll.java - How to generate payroll reports by
* department.
*
******************************************************************************
*
* Java GSS-API Plugin Samples
*
* JCCKerberosPlugin.java - How to implement a GSS-API Plugin that
* does Kerberos authentication using IBM
* DB2 Universal Driver.
* JCCKerberosPluginTest.java - How to use JCCKerberosPlugin to get a
* DB2 Connection using IBM DB2 Universal
* Driver.
* JCCSimpleGSSPlugin.java - How to implement a GSS-API Plugin that
* does userid and password checking using
* IBM DB2 Universal Driver.
* JCCSimpleGSSContext.java - implement a GSSContext to be used by
* JCCSimpleGSSPlugin
* JCCSimpleGSSCrednetial.java - implement a GSSCredential to be used by
* JCCSimpleGSSPlugin
* JCCSimpleGSSException.java - implement a GSSException to be used by
* JCCSimpleGSSPlugin
* JCCSimpleGSSName.java - implement a GSSName to be used by
* JCCSimpleGSSPlugin
* JCCSimpleGSSPluginTest.java - How to use JCCSimpleGSSPlugin to get a
* DB2 Connection using IBM DB2 Universal
* Driver.
*
******************************************************************************