|
Oracle Fusion Middleware Java API Reference for Oracle Extension SDK 11g Release 2 (11.1.2.2.0) E17493-03 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object
oracle.javatools.db.execute.StatementWrapper
oracle.javatools.db.execute.QueryWrapper
public class QueryWrapper
Execution wrapper for querying the database and processing ResultSets (rather than just executing statements). On top of what StatementWrapper
provides, it provides:
Example Usage:
final Database db = ...; final Schema schema = ...; final String query = ...; final QueryWrapper wrap = new QueryWrapper( db, query, new Object[]{ schema }); final QueryWrapper.QueryRunnable r = new QueryWrapper.QueryRunnable() { public void processResultSet( ResultSet rs ) throws DBException { try { while( rs.next() ) { // process the result set as appropriate } } catch( SQLException sqe ) { wrap.throwDBException( sqe ); } } }; try { wrap.executeQuery( r ); } catch( DBException dbe ) { // process exception }
Nested Class Summary | |
---|---|
static interface |
QueryWrapper.QueryRunnable A QueryRunnable implementation is passed to the QueryWrapper on execute of the query to process the resulting ResultSet. |
Nested classes/interfaces inherited from class oracle.javatools.db.execute.StatementWrapper |
---|
StatementWrapper.ExecutionProxy, StatementWrapper.ExecutionRunnable<T>, StatementWrapper.Listener |
Constructor Summary | |
---|---|
QueryWrapper(Database db, java.lang.String query) Creates a wrapper for a query with no parameters. |
|
QueryWrapper(Database db, java.lang.String query, java.util.List params) Creates a wrapper for the given query text. |
|
QueryWrapper(Database db, java.lang.String query, java.lang.Object... params) Creates a wrapper for the given query text. |
|
QueryWrapper(java.lang.String name, java.sql.Connection conn, java.lang.String query, java.lang.Object... params) Only use in the absence of a Database (e.g. |
Method Summary | |
---|---|
void |
close() Closes the statement and result set if we got that far. |
protected java.sql.Statement |
createStatment() Creates the Statement object to use. |
boolean |
execute() Executes the statment against the database. |
void |
executeQuery(int fetchSize, QueryWrapper.QueryRunnable run) Execute the query against the builder's connection using the appropriate parameter substitutions. |
void |
executeQuery(QueryWrapper.QueryRunnable run) Execute the query against the builder's connection using the appropriate parameter substitutions. |
protected java.util.List<java.lang.Object> |
getParameters() Returns the parameters to substitute on the statement. |
protected java.lang.String |
getQuery() Returns the query string. |
java.lang.String |
getStatementTextForLog() For logging and exception handling. |
static QueryWrapper |
union(QueryWrapper... wrappers) Unions together the queries in the given wrapper and bundles up all the parameters (if any) to be used with the various queries. |
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 |
---|
public QueryWrapper(Database db, java.lang.String query)
#QueryWrapper(java.sql.Connection, java.lang.String, java.lang.Object...)
public QueryWrapper(Database db, java.lang.String query, java.lang.Object... params)
public QueryWrapper(java.lang.String name, java.sql.Connection conn, java.lang.String query, java.lang.Object... params)
public QueryWrapper(Database db, java.lang.String query, java.util.List params)
Method Detail |
---|
protected java.sql.Statement createStatment() throws java.sql.SQLException
StatementWrapper
createStatment
in class StatementWrapper
java.sql.SQLException
public java.lang.String getStatementTextForLog()
StatementWrapper
getStatementTextForLog
in class StatementWrapper
protected java.lang.String getQuery()
setMessageFormat()
protected java.util.List<java.lang.Object> getParameters()
getQuery()
public final boolean execute() throws DBException
StatementWrapper
execute
in class StatementWrapper
DBException
Statement.execute(java.lang.String)
public void executeQuery(int fetchSize, QueryWrapper.QueryRunnable run) throws DBException
fetchSize
- Gives the JDBC driver a hint as to the number of rows that should be fetched from the database when more rows are needed. If the value specified is zero, then the hint is ignored.DBException
public void executeQuery(QueryWrapper.QueryRunnable run) throws DBException
DBException
public void close()
finally{ ... }
block.close
in class StatementWrapper
public static QueryWrapper union(QueryWrapper... wrappers)
No checking is done on the number of columns - the database will complain if they don't match.
|
Oracle Fusion Middleware Java API Reference for Oracle Extension SDK 11g Release 2 (11.1.2.2.0) E17493-03 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |