FileDocCategorySizeDatePackage
GetStoredProcedures.javaAPI DocExample2331Wed Jan 03 19:21:58 GMT 2001None

GetStoredProcedures

public class GetStoredProcedures extends Object

Fields Summary
Connection
conn
Constructors Summary
public GetStoredProcedures()

  try {
   DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
   conn = DriverManager.getConnection(
    "jdbc:oracle:thin:@dssw2k01:1521:orcl", "scott", "tiger");
  }
  catch (SQLException e) {
   System.err.println(e.getMessage());
   e.printStackTrace();
  }
 
Methods Summary
protected voidfinalize()

  if (conn != null) { try { conn.close(); } catch (SQLException ignore) { } }
  super.finalize();
 
public static voidmain(java.lang.String[] args)

  String storedProcedureName = null;
  String packageName         = null;
  String schemaName          = null;
  if (args.length > 0) 
   schemaName          = args[0];
  if (args.length > 2) {
   packageName         = args[1];
   storedProcedureName = args[2];
  }
  else if (args.length > 1){
   storedProcedureName = args[1];
  }
  new GetStoredProcedures().process(
   schemaName, packageName, storedProcedureName);
 
public voidprocess(java.lang.String schemaName, java.lang.String packageName, java.lang.String storedProcedureName)

  int row                     = 0;
  ResultSet rslt              = null;
  String catalog              = null;
  String schemaPattern        = "%";
  String procedureNamePattern = "%";
  try {
   if (schemaName != null && !schemaName.equals("")) 
    schemaPattern = schemaName;
   if (packageName != null && !packageName.equals("")) 
    catalog = packageName;
   if (storedProcedureName != null && !storedProcedureName.equals("")) 
    procedureNamePattern = storedProcedureName;
   rslt = conn.getMetaData().getProcedures(
    catalog,
    schemaPattern,
    procedureNamePattern );
   while (rslt.next()) {
    row++;
    if (rslt.getString(1) != null)
     System.out.println(rslt.getString(2) + 
      "." + rslt.getString(1) + 
      "." + rslt.getString(3));
    else
     System.out.println(rslt.getString(2) + 
      "." + rslt.getString(3));
   }
  }
  catch (SQLException e) {
   System.err.println("SQL Error: " + e.getMessage());
  }
  finally {
   if (rslt != null)  
    try { rslt.close();  } catch (SQLException ignore) { }
  }