Skip navigation links
oracle.javatools.db.execute
Class PlSqlWrapper
java.lang.Object
oracle.javatools.db.execute.StatementWrapper
oracle.javatools.db.execute.QueryWrapper
oracle.javatools.db.execute.PlSqlWrapper
-
public class PlSqlWrapper
- extends QueryWrapper
Wrapper for executing a stored procedure against the database using a CallableStatement.
- IN parameters are defined through the constructor (in the same way they are for normal queries).
- OUT parameters are included by the PlSqlRunnable passed to executePlSql.
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. |
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.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 |
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).
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
Skip navigation links
Copyright © 1997, 2012, Oracle. All rights reserved.