Oracle Fusion Middleware Java API Reference for Oracle Extension SDK
11g Release 2 (11.1.2.0.0)

E17493-01

oracle.javatools.db.execute
Class PlSqlWrapper

java.lang.Object
  extended by oracle.javatools.db.execute.StatementWrapper
      extended by oracle.javatools.db.execute.QueryWrapper
          extended by oracle.javatools.db.execute.PlSqlWrapper

public class PlSqlWrapper
extends QueryWrapper

Wrapper for executing a stored procedure against the database using a CallableStatement.

Example usage of a query String (query) that has one IN parameter (param1) and one OUT parameter.
   final PlSqlWrapper wrap = new PlSqlWrapper( db, query, param1 );
   wrap.executePlSql(
     new PlSqlRunnable()
     {
       public void prepareCall( CallableStatement cs )
       throws SQLException
       {
         cs.registerOutParameter( 2, Types.INTEGER );
       }

       public void processCall( CallableStatement cs )
       throws SQLException
       {
         final int outParam = cs.getInt(2);
         // we have our output!
       }
     } );
 

Since:
11.1.1.2.0

Nested Class Summary
static class PlSqlWrapper.PlSqlRunnable
          Runnable passed to the PlSqlWrapper to process the ResultSet and/or CallableStatement during execution.
 
Nested classes/interfaces inherited from class oracle.javatools.db.execute.QueryWrapper
QueryWrapper.QueryRunnable
 
Nested classes/interfaces inherited from class oracle.javatools.db.execute.StatementWrapper
StatementWrapper.ExecutionProxy, StatementWrapper.ExecutionRunnable<T>, StatementWrapper.Listener
 
Constructor Summary
PlSqlWrapper(Database db, java.lang.String plsql, java.lang.Object... params)
          Creates a new wrapper for executing pl/sql, specifying the pl/sql itself and any IN parameters.
PlSqlWrapper(java.lang.String name, java.sql.Connection conn, java.lang.String plsql, java.lang.Object... params)
          Only use in the absence of a Database (e.g.
 
Method Summary
protected  java.sql.Statement createStatment()
          Creates the Statement object to use.
 void executePlSql(PlSqlWrapper.PlSqlRunnable runner)
          Executes the stored procedure and processes the resulting ResultSet and CallableStatement with the given runner.
 
Methods inherited from class oracle.javatools.db.execute.QueryWrapper
close, execute, executeQuery, executeQuery, getParameters, getQuery, getStatementTextForLog, union
 
Methods inherited from class oracle.javatools.db.execute.StatementWrapper
addListener, doExecute, executeImpl, getConnection, getConnectionName, getDatabase, getExecutionProxy, getIdentifier, getStatement, getStatementStrings, hasCancelled, isIgnoreErrors, queryFinished, queryStarted, removeListener, setBypassExecutionProxy, setDatabase, setExecuting, setExecutionProxy, setIdentifier, setIgnoreErrors, setStatement, sqlTrace, throwDBException, throwDBException, throwDBException
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PlSqlWrapper

public PlSqlWrapper(Database db,
                    java.lang.String plsql,
                    java.lang.Object... params)
Creates a new wrapper for executing pl/sql, specifying the pl/sql itself and any IN parameters.

Parameters:
db - the database to use for execution
query - the pl/sql to execute
params - any IN parameters for the pl/sql

PlSqlWrapper

public PlSqlWrapper(java.lang.String name,
                    java.sql.Connection conn,
                    java.lang.String plsql,
                    java.lang.Object... params)
Only use in the absence of a Database (e.g. in unit tests).

Method Detail

createStatment

protected java.sql.Statement createStatment()
                                     throws java.sql.SQLException
Description copied from class: StatementWrapper
Creates the Statement object to use. By default this creates a simple Statement, subclasses can override to create a Prepared or Callable statement.

Overrides:
createStatment in class QueryWrapper
Throws:
java.sql.SQLException

executePlSql

public void executePlSql(PlSqlWrapper.PlSqlRunnable runner)
                  throws DBException
Executes the stored procedure and processes the resulting ResultSet and CallableStatement with the given runner.

Parameters:
runner - to process the ResultSet and CallableStatement
Throws:
DBException - for any errors

Oracle Fusion Middleware Java API Reference for Oracle Extension SDK
11g Release 2 (11.1.2.0.0)

E17493-01

Copyright © 1997, 2011, Oracle. All rights reserved.