User Tools

Site Tools


software:db2:using_cli

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
software:db2:using_cli [2013/11/25 15:59] seelasoftware:db2:using_cli [Unknown date] (current) – removed - external edit (Unknown date) 127.0.0.1
Line 1: Line 1:
-====== Sample Scripts & Embedded SQL ====== 
  
- 
-**All sample programs are taken for either IBM's website or from past 3421 courses. 
-Embedded SQL is another type of application that will need packages bound 
-against a database so that it can execute its SQL. 
-Embedded applications can be written in a number of host languages. C\C++, JAVA(SQLJ), COBOL and FORTRAN** \\ 
-\\ 
- 
- 
----- 
- 
-====Table Creation for Sample Programs==== 
- 
----- 
-Connect to the database you are using for your course 
- 
-**Table sailor** \\ 
- 
-<code> 
-create table sailor ( 
-   sid   smallint  not null, 
-    sname  varchar(20), 
-    rating smallint, 
-    age smallint, 
-        primary key (sid) 
-); 
- 
- 
-insert into sailor ( sid, sname,rating,age) values 
-(22,'Dustin',7,45.0), 
-(29,'BRUTUS',1,33.0), 
-(31,'Lubber', 8,55.5), 
-(32,'Andy',8, 25.5), 
-(58,'Rusty',10,35.0), 
-(64,'Horatio',7,35.0), 
-(71,'Zorba',10,16.0), 
-(74,'Horatio',9,40.0), 
-(85,'Art',3,25.5), 
-(95,'Bob',3,63.5); 
- 
-</code> 
- 
-Once created successfully 
-<code> 
-db2 "select * from sailor" 
- 
-SID    SNAME                RATING    AGE     
------- -------------------- ------ -------- 
-    22 Dustin                    7     45.0 
-    29 BRUTUS                    1     33.0 
-    31 Lubber                    8     55.5 
-    32 Andy                      8     25.5 
-    58 Rusty                    10     35.0 
-    64 Horatio                       35.0 
-    71 Zorba                    10     16.0 
-    74 Horatio                       40.0 
-    85 Art                           25.5 
-    95 Bob                           63.5 
- 
-  10 record(s) selected. 
- 
-</code> 
- 
----- 
- 
-====Sample Java Program==== 
-\\ 
-\\ 
---- 
-<code> 
- 
-Program to test connectivity to database sample 
-</code> 
-\\ 
-{{:software:db2:ezjava.java|Sample Connectivity type 4 driver}} 
-\\ 
-<code> 
- 
-Steps to Compile: source db2cshrc 
-                  javac  ezjava.java 
-                  Execute : java ezjava <database name > <username> <user password> 
-                                         sample 
-</code> 
-\\ 
-\\ 
- 
-{{:software:db2:ezsailor.java| Sample Java Sailor Program }} 
-\\ 
-\\ 
- 
- 
-This file will be downloaded as **ezsailor.java** 
-Rename the file to **EzSailor.java** 
-Use this file for testing because you will have to create your 
-own table and modify the fields 
- 
-\\ 
-\\ 
----- 
-<code> 
- 
-   Source the client's profile 
-   source ~db2leduc/sqllib/db2cshrc 
-    
-   Compile the program 
-      javac EzSailor.java 
-    
-   Execute the program 
- 
-      java EzSailor sample where sample is  the database I used to store my tables 
- 
-</code> 
- 
-====Sample Perl Program==== 
- 
- 
-{{:software:db2:sailor.pl|Sample Perl Program}} 
- 
-====Sample Sqlj Program==== 
- 
-{{:software:db2:sailors.sqlj|Sample Sqlj Program}} 
-    
- 
-For sqlj programs, you would need  
-   * a sqlj precompiler which translates file.sqlj into java pgms. 
-   * a java compiler  
-   * Sqlj runtime classes (available *.zip) 
-      -sqlj.runtime 
-      - sqlj.runtime.ref  
-      - sqlj.runtime.profile  
-      - sqlj.runtime.profile.ref 
-    *  A jdbc driver implementing package java.sql 
- 
-**How to execute the sqlj** \\  
-\\ 
----- 
-\\ 
-This program uses the universal type 2 driver 
- 
-Steps to follow 
- 
-    source the client's cshrc file  
-       - ~db2leduc/sqllib/db2cshrc 
-    Pre-compile the program (Running it through a translator)  
-       -This will strip the java code from the sql code within the sqlj program and  create sub files. (Program name sqlj) eg sqlj <programname> 
- 
-    Use db2sqljcustomize to process the SQLJ profile (.ser).  
-       - The SQLJ customization process binds four packages to the DB2 server. - To run execute " db2sqljcustomize -url jdbc:db2:c3421m sailor_SJProfile0.ser" 
-    
-    Run your java program  
-       - java sailor 71 
-     
- 
-         
- 
-  
software/db2/using_cli.1385413192.txt.gz · Last modified: 2013/11/25 15:59 by seela

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki