User Tools

Site Tools


software:db2:using_cli

This is an old revision of the document!


Using 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

 Java - Sample Program  

Sample Java Program

This file will be downloaded as ezjava.java Rename the file to EzJava.java

 Source the client's profile
    source ~db2leduc/sqllib/db2cshrc
 
 Compile the program
    javac EzJava.java
 
 Execute the program
     java EzJava sample
  • Perl Sample Program

Sample Perl Program

  • Sqlj

Sample Sqlj Program

For Sqlj, you would need

  1. a sqlj translator which translates file.sqlj into java pgms.
  2. A java compiler
  3. Sqlj runtime classes (available *.zip)
    1. sqlj.runtime
    2. sqlj.runtime.ref
    3. sqlj.runtime.profile
    4. sqlj.runtime.profile.ref
  4. A jdbc driver implementing package java.sql

How to execute the sqlj

  • source the client's cshrc file
    1. ~db2leduc/sqllib/db2cshrc
  • Pre-compile the program (Running it through a translator)
    1. This will strip the java code from the sql code within the sqlj program and create sub files. (Program name sqlj)
  • Use db2sqljcustomize to process the SQLJ profile (.ser).
    1. The SQLJ customization process binds four packages to the DB2 server. - To run execute db2sqljcustomize -url jdbc:db2:c3421m sage_SJProfile0.ser
  • Run your java program
    1. java sage 71
software/db2/using_cli.1362154032.txt.gz · Last modified: 2013/03/01 11:07 by seela

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki