package org.okip.service.dbc.api;



/*
   Copyright (c) 2002 Massachusetts Institute of Technology

   This work, including any software, documents, or other related items
   (the "Work"), is being provided by the copyright holder(s) subject to
   the terms of the MIT OKI(TM) API Definition License. By obtaining,
   using and/or copying this Work, you agree that you have read,
   understand, and will comply with the following terms and conditions of
   the MIT OKI(TM) API Definition License:

   You may use, copy, and distribute unmodified versions of this Work for
   any purpose, without fee or royalty, provided that you include the
   following on ALL copies of the Work that you make or distribute:

    *  The full text of the MIT OKI(TM) API Definition License in a
       location viewable to users of the redistributed Work.

    *  Any pre-existing intellectual property disclaimers, notices, or
       terms and conditions. If none exist, a short notice similar to the
       following should be used within the body of any redistributed
       Work: "Copyright (c) 2002 Massachusetts Institute of Technology. All
       Rights Reserved."

   You may modify or create Derivatives of this Work only for your
   internal purposes. You shall not distribute or transfer any such
   Derivative of this Work to any location or any other third party. For
   purposes of this license, "Derivative" shall mean any derivative of
   the Work as defined in the United States Copyright Act of 1976, such
   as a translation or modification.

   THIS WORK PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
   IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
   CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
   TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE WORK
   OR THE USE OR OTHER DEALINGS IN THE WORK.

   The name and trademarks of copyright holder(s) and/or MIT may NOT be
   used in advertising or publicity pertaining to the Work without
   specific, written prior permission. Title to copyright in the Work and
   any associated documentation will at all times remain with the
   copyright holders.

*/

/*
 * $Source: /cvs/oki/tech/src/org/okip/service/dbc/api/Statement.java,v $
 */

/**
 * The object used for executing a static SQL statement and returning the results it produces.
 * <p>
 * Licensed under the {@link org.okip.service.ApiLicense MIT OKI&#153; API Definition License}.
 *
 * @version $Name:  $ / $Revision: 1.9 $ / $Date: 2002/08/30 19:28:46 $
 */
public interface Statement
extends java.io.Serializable {

  /**
   * Adds the given SQL command to
   * the current list of commmands
   * for this Statement object.
   *
   * @param sql
   *
   * @throws DbcException
   *
   */
  void addBatch(String sql)
  throws DbcException;

  /**
   * Cancels this Statement object
   * if both the DBMS and driver support
   * aborting an SQL statement.
   *
   * @throws DbcException
   *
   */
  void cancel()
  throws DbcException;

  /**
   * Empties this Statement object's
   * current list of SQL commands.
   *
   * @throws DbcException
   *
   */
  void clearBatch()
  throws DbcException;

  /**
   * Clears all the warnings reported on this Statement object.
   *
   * @throws DbcException
   *
   */
  void clearWarnings()
  throws DbcException;

  /**
  * Releases this Statement object's
  * database and JDBC resources immediately
  * instead of waiting for this to happen
  * when it is automatically closed.
  *
  * @throws DbcException
  *
  */
  void close()
  throws DbcException;

  /**
   * Executes the given SQL statement,
   * which may return multiple results.
   *
   * @param sql
   *
   * @return boolean
   *
   * @throws DbcException
   *
   */
  boolean execute(String sql)
  throws DbcException;

  /**
   * Executes the given SQL statement,
   * which may return multiple results, and
   * signals the driver that any
   * auto-generated keys should be made
   * available for retrieval.
   *
   * @param sql
   * @param autoGeneratedKeys
   *
   * @return boolean
   *
   * @throws DbcException
   *
   */
//  boolean execute(String sql, int autoGeneratedKeys)
//  throws DbcException;

  /**
   * Executes the given SQL statement,
   * which may return multiple results, and
   * signals the driver that the
   * auto-generated keys indicated
   * in the given array should be
   * made available for retrieval.
   *
   * @param sql
   * @param columnIndexes
   *
   * @return boolean
   *
   * @throws DbcException
   *
   */
//  boolean execute(String sql, int[] columnIndexes)
//  throws DbcException;

  /**
   * Executes the given SQL statement,
   * which may return multiple results, and
   * signals the driver that the
   * auto-generated keys indicated
   * in the given array should be
   * made available for retrieval.
   *
   * @param sql
   * @param columnNames
   *
   * @return boolean
   *
   * @throws DbcException
   *
   */
//  boolean execute(String sql, String[] columnNames)
//  throws DbcException;

  /**
   * Submits a batch of commands to the
   * database for execution and if all
   * commands execute successfully,
   * returns an array of update counts.
   *
   * @return int[]
   *
   * @throws DbcException
   *
   */
  int[] executeBatch()
  throws DbcException;

  /**
   * Executes the given SQL statement,
   * which returns a single ResultSet object.
   *
   * @param sql
   *
   * @return ResultSet
   *
   * @throws DbcException
   *
   */
  ResultSet executeQuery(String sql)

  throws DbcException;

  /**
   * Executes the given SQL statement,
   * which may be an INSERT, UPDATE, or
   * DELETE statement or an SQL statement
   * that returns nothing, such as an SQL DDL
   * statement.
   *
   * @param sql
   *
   * @return int
   *
   * @throws DbcException
   *
   */
  int executeUpdate(String sql)
  throws DbcException;

  /**
   * Executes the given SQL statement and
   * signals the driver with the given flag
   * about whether the auto-generated keys
   * produced by this Statement object
   * should be made available for retrieval.
   *
   * @param sql
   * @param autoGeneratedKeys
   *
   * @return int
   *
   * @throws DbcException
   *
   */
//  int executeUpdate(String sql, int autoGeneratedKeys)
//  throws DbcException;

  /**
   * Executes the given SQL statement and signals
   * the driver that the auto-generated keys
   * indicated in the given array should be
   * made available for retrieval.
   *
   * @param sql
   * @param columnIndexes
   *
   * @return int
   *
   * @throws DbcException
   *
   */
//  int executeUpdate(String sql, int[] columnIndexes)
//  throws DbcException;

  /**
   * Executes the given SQL statement and signals
   * the driver that the auto-generated keys
   * indicated in the given array should be
   * made available for retrieval.
   *
   * @param sql
   * @param columnNames
   *
   * @return int
   *
   * @throws DbcException
   *
   */
//  int executeUpdate(String sql, String[] columnNames)
//  throws DbcException;

  /**
   * Retrieves the Connection object that
   * produced this Statement object.
   *
   * @return Connection
   *
   * @throws DbcException
   *
   */
  Connection getConnection()
  throws DbcException;

  /**
   * Retrieves the direction for fetching rows
   * from database tables that is the
   * default for result sets generated
   * from this Statement object.
   *
   * @return int
   *
   * @throws DbcException
   *
   */
  int getFetchDirection()
  throws DbcException;

  /**
   * Retrieves the number of result set rows
   * that is the default fetch size for
   * ResultSet  objects generated
   * from this Statement object.
   *
   * @return int
   *
   * @throws DbcException
   *
   */
  int getFetchSize()
  throws DbcException;

  /**
   * Retrieves any auto-generated keys created
   * as a result of executing this Statement object.
   *
   * @return ResultSet
   *
   * @throws DbcException
   *
   */
  ResultSet getGeneratedKeys()
  throws DbcException;

  /**
   * Retrieves the maximum number of bytes
   * that can be returned for character and
   * binary column values in a ResultSet object
   * produced by this Statement object.
   *
   * @return int
   *
   * @throws DbcException
   *
   */
  int getMaxFieldSize()
  throws DbcException;

  /**
   * Retrieves the maximum number of rows
   * that a ResultSet object produced by
   * this Statement object can contain.
   *
   * @return int
   *
   * @throws DbcException
   *
   */
  int getMaxRows()
  throws DbcException;

  /**
   * Moves to this Statement object's next result,
   * returns true if it is a ResultSet  object,
   * and implicitly closes any current ResultSet
   * object(s) obtained with the method getResultSet.
   *
   * @return boolean
   *
   * @throws DbcException
   *
   */
  boolean getMoreResults()
  throws DbcException;

  /**
   * Moves to this Statement object's next result,
   * deals with any current ResultSet object(s)
   * according to the instructions specified
   * by the given flag, and returns true
   * if the next result is a ResultSet object.
   *
   * @param current
   *
   * @return boolean
   *
   * @throws DbcException
   *
   */
  boolean getMoreResults(int current)
  throws DbcException;

  /**
   * Retrieves the number of seconds the driver
   * will wait for a Statement object to execute.
   *
   * @return int
   *
   * @throws DbcException
   *
   */
  int getQueryTimeout()
  throws DbcException;

  /**
   * Retrieves the current result as a ResultSet object.
   *
   * @return ResultSet
   *
   * @throws DbcException
   *
   */
  ResultSet getResultSet()
  throws DbcException;

  /**
   * Retrieves the result set concurrency for
   * ResultSet objects generated by this
   * Statement object.
   *
   * @return int
   *
   * @throws DbcException
   *
   */
  int getResultSetConcurrency()
  throws DbcException;

  /**
   * Retrieves the result set holdability for
   * ResultSet objects generated by this
   * Statement object.
   *
   * @return int
   *
   * @throws DbcException
   *
   */
  int getResultSetHoldability()
  throws DbcException;

  /**
   * Retrieves the result set type for
   * ResultSet objects generated by this
   * Statement object.
   *
   * @return int
   *
   * @throws DbcException
   *
   */
  int getResultSetType()
  throws DbcException;

  /**
   * Retrieves the current result as an update count;
   * if the result is a ResultSet object or there are
   * no more results, -1 is returned.
   *
   * @return int
   *
   * @throws DbcException
   *
   */
  int getUpdateCount()
  throws DbcException;

  /**
   * Retrieves the first warning reported
   * by calls on this Statement object.
   *
   * @return SQLWarning
   *
   * @throws DbcException
   *
   */
  java.sql.SQLWarning getWarnings()
  throws DbcException;

  /**
   * Sets the SQL cursor name to the given String,
   * which will be used by subsequent Statement
   * object execute methods.
   *
   * @param name
   *
   * @throws DbcException
   *
   */
  void setCursorName(String name)
  throws DbcException;

  /**
   * Sets escape processing on or off.
   *
   * @param enable
   *
   * @throws DbcException
   *
   */
  void setEscapeProcessing(boolean enable)
  throws DbcException;

  /**
   * Gives the driver a hint as to the direction
   * in which rows will be processed in ResultSet
   * objects created using this Statement object.
   *
   * @param direction
   *
   * @throws DbcException
   *
   */
  void setFetchDirection(int direction)
  throws DbcException;

  /**
   * Gives the JDBC driver a hint as to the number
   * of rows that should be fetched from the
   * database when more rows are needed.
   *
   * @param rows
   *
   * @throws DbcException
   *
   */
  void setFetchSize(int rows)
  throws DbcException;

  /**
   * Sets the limit for the maximum number of bytes
   * in a ResultSet column storing character or
   * binary values to the given number of bytes.
   *
   * @param max
   *
   * @throws DbcException
   *
   */
  void setMaxFieldSize(int max)
  throws DbcException;

  /**
   * Sets the limit for the maximum number of rows
   * that any ResultSet object can contain
   * to the given number.
   *
   * @param max
   *
   * @throws DbcException
   *
   */
  void setMaxRows(int max)
  throws DbcException;

  /**
   * Sets the number of seconds the driver
   * will wait for a Statement object to
   * execute to the given number of seconds.
   *
   * @param seconds
   *
   * @throws DbcException
   *
   */
  void setQueryTimeout(int seconds)
  throws DbcException;

}
