× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



>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


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.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 on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.