mondrian.rolap
Class SqlStatement

java.lang.Object
  extended by mondrian.rolap.SqlStatement

public class SqlStatement
extends Object

SqlStatement contains a SQL statement and associated resources throughout its lifetime.

The goal of SqlStatement is to make tracing, error-handling and resource-management easier. None of the methods throws a SQLException; if an error occurs in one of the methods, the method wraps the exception in a RuntimeException describing the high-level operation, logs that the operation failed, and throws that RuntimeException.

If methods succeed, the method generates lifecycle logging such as the elapsed time and number of rows fetched.

There are a few obligations on the caller. The caller must:

The close() method is idempotent. You are welcome to call it more than once.

SqlStatement is not thread-safe.

Since:
2.3
Version:
$Id: //open/mondrian-release/3.0/src/main/mondrian/rolap/SqlStatement.java#3 $
Author:
jhyde

Field Summary
 int rowCount
           
 
Constructor Summary
SqlStatement(DataSource dataSource, String sql, int maxRows, String component, String message, int resultSetType, int resultSetConcurrency)
           
 
Method Summary
 void close()
          Closes all resources (statement, result set) held by this SqlStatement.
 void execute()
           
 ResultSet getResultSet()
           
 RuntimeException handle(Exception e)
          Handles an exception thrown from the ResultSet, implicitly calls close(), and returns an exception which includes the full stack, including a description of the high-level operation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

rowCount

public int rowCount
Constructor Detail

SqlStatement

SqlStatement(DataSource dataSource,
             String sql,
             int maxRows,
             String component,
             String message,
             int resultSetType,
             int resultSetConcurrency)
Method Detail

execute

public void execute()
             throws SQLException
Throws:
SQLException

close

public void close()
Closes all resources (statement, result set) held by this SqlStatement.

If any of them fails, wraps them in a RuntimeException describing the high-level operation which this statement was performing. No further error-handling is required to produce a descriptive stack trace, unless you want to absorb the error.


getResultSet

public ResultSet getResultSet()

handle

public RuntimeException handle(Exception e)
Handles an exception thrown from the ResultSet, implicitly calls close(), and returns an exception which includes the full stack, including a description of the high-level operation.

Parameters:
e - Exception
Returns:
Runtime exception

SourceForge.net_Logo