mondrian.olap4j
Class MondrianOlap4jStatement

java.lang.Object
  extended by mondrian.server.StatementImpl
      extended by mondrian.olap4j.MondrianOlap4jStatement
All Implemented Interfaces:
Wrapper, Statement, OlapStatement, OlapWrapper
Direct Known Subclasses:
MondrianOlap4jPreparedStatement

abstract class MondrianOlap4jStatement
extends StatementImpl
implements OlapStatement, Statement

Implementation of OlapStatement for the Mondrian OLAP engine.

Since:
May 24, 2007
Author:
jhyde

Field Summary
protected  boolean closeOnCompletion
          Support for #closeOnCompletion() method.
(package private)  MondrianOlap4jConnection olap4jConnection
           
(package private)  MondrianOlap4jCellSet openCellSet
          Current cell set, or null if the statement is not executing anything.
 
Fields inherited from class mondrian.server.StatementImpl
query, queryTimeout
 
Fields inherited from interface java.sql.Statement
CLOSE_ALL_RESULTS, CLOSE_CURRENT_RESULT, EXECUTE_FAILED, KEEP_CURRENT_RESULT, NO_GENERATED_KEYS, RETURN_GENERATED_KEYS, SUCCESS_NO_INFO
 
Constructor Summary
MondrianOlap4jStatement(MondrianOlap4jConnection olap4jConnection)
           
 
Method Summary
 void addBatch(String sql)
           
 void addListener(CellSetListener.Granularity granularity, CellSetListener cellSetListener)
           
 void cancel()
          Issues a cancel request on this statement.
 void clearBatch()
           
 void clearWarnings()
           
 void close()
          Closes this statement.
 boolean execute(String sql)
           
 boolean execute(String sql, int autoGeneratedKeys)
           
 boolean execute(String sql, int[] columnIndexes)
           
 boolean execute(String sql, String[] columnNames)
           
 int[] executeBatch()
           
 CellSet executeOlapQuery(SelectNode selectNode)
           
 CellSet executeOlapQuery(String mdx)
           
protected  CellSet executeOlapQueryInternal(Query query, MondrianOlap4jCellSetMetaData cellSetMetaData)
          Executes a parsed query, closing any previously open cellset.
 ResultSet executeQuery(String mdx)
           
(package private)  ResultSet executeQuery2(String mdx, boolean advanced, String tabFields, int[] rowCountSlot)
           
 int executeUpdate(String sql)
           
 int executeUpdate(String sql, int autoGeneratedKeys)
           
 int executeUpdate(String sql, int[] columnIndexes)
           
 int executeUpdate(String sql, String[] columnNames)
           
 OlapConnection getConnection()
           
 int getFetchDirection()
           
 int getFetchSize()
           
 ResultSet getGeneratedKeys()
           
 int getMaxFieldSize()
           
 int getMaxRows()
           
 RolapConnection getMondrianConnection()
          Returns this statement's connection.
 boolean getMoreResults()
           
 boolean getMoreResults(int current)
           
 int getQueryTimeout()
           
 ResultSet getResultSet()
           
 int getResultSetConcurrency()
           
 int getResultSetHoldability()
           
 int getResultSetType()
           
 int getUpdateCount()
           
 SQLWarning getWarnings()
           
 boolean isClosed()
           
 boolean isPoolable()
           
 boolean isWrapperFor(Class<?> iface)
           
(package private)  void onResultSetClose(ResultSet resultSet)
          Called by each child result set (most likely a cell set) when it is closed.
protected  Pair<Query,MondrianOlap4jCellSetMetaData> parseQuery(String mdx)
           
 void setCursorName(String name)
           
 void setEscapeProcessing(boolean enable)
           
 void setFetchDirection(int direction)
           
 void setFetchSize(int rows)
           
 void setMaxFieldSize(int max)
           
 void setMaxRows(int max)
           
 void setPoolable(boolean poolable)
           
 void setQueryTimeout(int seconds)
           
 void start(Execution execution)
          Starts an execution.
<T> T
unwrap(Class<T> iface)
           
 
Methods inherited from class mondrian.server.StatementImpl
checkCancelOrTimeout, enableProfiling, end, getCurrentExecution, getId, getProfileHandler, getProperty, getQuery, getQueryTimeoutMillis, getSchema, getSchemaReader, setQuery, setQueryTimeoutMillis
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface mondrian.server.Statement
checkCancelOrTimeout, enableProfiling, end, getCurrentExecution, getId, getProfileHandler, getProperty, getQuery, getQueryTimeoutMillis, getSchema, getSchemaReader, setQuery, setQueryTimeoutMillis
 

Field Detail

olap4jConnection

final MondrianOlap4jConnection olap4jConnection

closeOnCompletion

protected boolean closeOnCompletion
Support for #closeOnCompletion() method.


openCellSet

MondrianOlap4jCellSet openCellSet
Current cell set, or null if the statement is not executing anything. Any method which modifies this member must synchronize on the MondrianOlap4jStatement.

Constructor Detail

MondrianOlap4jStatement

MondrianOlap4jStatement(MondrianOlap4jConnection olap4jConnection)
Method Detail

executeQuery

public ResultSet executeQuery(String mdx)
                       throws SQLException
Throws:
SQLException

executeQuery2

ResultSet executeQuery2(String mdx,
                        boolean advanced,
                        String tabFields,
                        int[] rowCountSlot)
                  throws SQLException
Throws:
SQLException

executeUpdate

public int executeUpdate(String sql)
                  throws SQLException
Throws:
SQLException

close

public void close()
Description copied from interface: Statement
Closes this statement.

Specified by:
close in interface Statement

getMaxFieldSize

public int getMaxFieldSize()
                    throws SQLException
Throws:
SQLException

setMaxFieldSize

public void setMaxFieldSize(int max)
                     throws SQLException
Throws:
SQLException

getMaxRows

public int getMaxRows()
               throws SQLException
Throws:
SQLException

setMaxRows

public void setMaxRows(int max)
                throws SQLException
Throws:
SQLException

setEscapeProcessing

public void setEscapeProcessing(boolean enable)
                         throws SQLException
Throws:
SQLException

getQueryTimeout

public int getQueryTimeout()
                    throws SQLException
Throws:
SQLException

setQueryTimeout

public void setQueryTimeout(int seconds)
                     throws SQLException
Throws:
SQLException

cancel

public void cancel()
            throws SQLException
Description copied from interface: Statement
Issues a cancel request on this statement.

Once the thread running the statement detects the cancel request, execution will throw an exception. See BasicQueryTest.testCancel for an example of usage of this method.

Specified by:
cancel in interface Statement
Overrides:
cancel in class StatementImpl
Throws:
SQLException - on error

getWarnings

public SQLWarning getWarnings()
                       throws SQLException
Throws:
SQLException

clearWarnings

public void clearWarnings()
                   throws SQLException
Throws:
SQLException

setCursorName

public void setCursorName(String name)
                   throws SQLException
Throws:
SQLException

execute

public boolean execute(String sql)
                throws SQLException
Throws:
SQLException

getResultSet

public ResultSet getResultSet()
                       throws SQLException
Throws:
SQLException

getUpdateCount

public int getUpdateCount()
                   throws SQLException
Throws:
SQLException

getMoreResults

public boolean getMoreResults()
                       throws SQLException
Throws:
SQLException

setFetchDirection

public void setFetchDirection(int direction)
                       throws SQLException
Throws:
SQLException

getFetchDirection

public int getFetchDirection()
                      throws SQLException
Throws:
SQLException

setFetchSize

public void setFetchSize(int rows)
                  throws SQLException
Throws:
SQLException

getFetchSize

public int getFetchSize()
                 throws SQLException
Throws:
SQLException

getResultSetConcurrency

public int getResultSetConcurrency()
                            throws SQLException
Throws:
SQLException

getResultSetType

public int getResultSetType()
                     throws SQLException
Throws:
SQLException

addBatch

public void addBatch(String sql)
              throws SQLException
Throws:
SQLException

clearBatch

public void clearBatch()
                throws SQLException
Throws:
SQLException

executeBatch

public int[] executeBatch()
                   throws SQLException
Throws:
SQLException

getConnection

public OlapConnection getConnection()
Specified by:
getConnection in interface OlapStatement

getMoreResults

public boolean getMoreResults(int current)
                       throws SQLException
Throws:
SQLException

getGeneratedKeys

public ResultSet getGeneratedKeys()
                           throws SQLException
Throws:
SQLException

executeUpdate

public int executeUpdate(String sql,
                         int autoGeneratedKeys)
                  throws SQLException
Throws:
SQLException

executeUpdate

public int executeUpdate(String sql,
                         int[] columnIndexes)
                  throws SQLException
Throws:
SQLException

executeUpdate

public int executeUpdate(String sql,
                         String[] columnNames)
                  throws SQLException
Throws:
SQLException

execute

public boolean execute(String sql,
                       int autoGeneratedKeys)
                throws SQLException
Throws:
SQLException

execute

public boolean execute(String sql,
                       int[] columnIndexes)
                throws SQLException
Throws:
SQLException

execute

public boolean execute(String sql,
                       String[] columnNames)
                throws SQLException
Throws:
SQLException

getResultSetHoldability

public int getResultSetHoldability()
                            throws SQLException
Throws:
SQLException

isClosed

public boolean isClosed()
                 throws SQLException
Throws:
SQLException

setPoolable

public void setPoolable(boolean poolable)
                 throws SQLException
Throws:
SQLException

isPoolable

public boolean isPoolable()
                   throws SQLException
Throws:
SQLException

unwrap

public <T> T unwrap(Class<T> iface)
         throws SQLException
Specified by:
unwrap in interface Wrapper
Specified by:
unwrap in interface OlapWrapper
Throws:
SQLException

isWrapperFor

public boolean isWrapperFor(Class<?> iface)
                     throws SQLException
Specified by:
isWrapperFor in interface Wrapper
Specified by:
isWrapperFor in interface OlapWrapper
Throws:
SQLException

executeOlapQuery

public CellSet executeOlapQuery(String mdx)
                         throws OlapException
Specified by:
executeOlapQuery in interface OlapStatement
Throws:
OlapException

parseQuery

protected Pair<Query,MondrianOlap4jCellSetMetaData> parseQuery(String mdx)
                                                        throws OlapException
Throws:
OlapException

executeOlapQueryInternal

protected CellSet executeOlapQueryInternal(Query query,
                                           MondrianOlap4jCellSetMetaData cellSetMetaData)
                                    throws OlapException
Executes a parsed query, closing any previously open cellset.

Parameters:
query - Parsed query
cellSetMetaData - Cell set metadata
Returns:
Cell set
Throws:
OlapException - if a database error occurs

start

public void start(Execution execution)
Description copied from interface: Statement
Starts an execution.

Specified by:
start in interface Statement
Overrides:
start in class StatementImpl
Parameters:
execution - Execution context

executeOlapQuery

public CellSet executeOlapQuery(SelectNode selectNode)
                         throws OlapException
Specified by:
executeOlapQuery in interface OlapStatement
Throws:
OlapException

addListener

public void addListener(CellSetListener.Granularity granularity,
                        CellSetListener cellSetListener)
                 throws OlapException
Specified by:
addListener in interface OlapStatement
Throws:
OlapException

getMondrianConnection

public RolapConnection getMondrianConnection()
Description copied from interface: Statement
Returns this statement's connection.

Specified by:
getMondrianConnection in interface Statement
Returns:
connection

onResultSetClose

void onResultSetClose(ResultSet resultSet)
Called by each child result set (most likely a cell set) when it is closed.

Parameters:
resultSet - Result set or cell set

Get Mondrian at SourceForge.net. Fast, secure and free Open Source software downloads