MIDRANGE dot COM Mailing List Archive



Home » JAVA400-L » August 2002

IBM SP example (was How can I find out what JAR file has a class?)



fixed

>Sorry, I've never heard of the StoredProcedure class.

Don't sweat it my friend.  It's all new and kinky to me.  I also misspelt
it.  It's StoredProc, not that it matters.  Prowling through db2_classes
shows there's no 'Stored' anything in there.

>What is it's fully qualified name (with the package).
>Where did you find out about this class.  I don't think
>there is such a thing in standard JDBC.

Beats me if it's standard JDBC or not.
SQL Concepts, V5R1 pp 158-161, Considerations for SP's written in Java.
Especially the section on DB2GENERAL parameter style.  The following is
copy/pasted directly from that manual.

o The class which defines a Java stored procedure
  must ?extend?, or be a subclass of, the Java
  com.ibm.db2.app.StoredProc class.
o The Java method must be a public void instance method.
o The parameters of the Java method must be
  SQL-compatible types.
o A Java method may test for a SQL NULL value
  using the isNull( ) method.
o The Java method must explicitly set the return
  parameters using the set( ) method.
o The Java method may access the current database
  using the getConnection ( ) method.
o The compiled class file must reside in the
  /QIBM/UserData/OS400/SQLLib/Function directory.

package mystuff;

import com.ibm.db2.app.*;
import java.sql.*;

public class sample2 extends StoredProc {
  public void donut(String query, int rowCount,
    String sqlstate) throws Exception {
  try {
    Statement s=getConnection().createStatement();
    ResultSet r=s.executeQuery(query);
    int counter=0;
    while(r.next()){
      counter++;
    }
    r.close(); s.close();
    set(2, counter);
    }catch(SQLException x){
    set(3, x.getSQLState());
    }
  }
}

  --buck






Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2014 by MIDRANGE dot COM and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available here. If you have questions about this, please contact