Index (Frames) | Index (No Frames) | Package | Package Tree | Tree
java.sql

Interface Statement

java.lang.Object
|
+--java.sql.Statement


public interface Statement

This interface provides a mechanism for executing SQL statements.

Author:

Field Summary

static intCLOSE_ALL_RESULTS

static intCLOSE_CURRENT_RESULT

This interface provides a mechanism for executing SQL statements.
static intEXECUTE_FAILED

static intKEEP_CURRENT_RESULT

static intNO_GENERATED_KEYS

static intRETURN_GENERATED_KEYS

static intSUCCESS_NO_INFO

Method Summary

voidaddBatch(java.lang.String sql)

This method adds a SQL statement to a SQL batch.
voidcancel()

This method cancels an outstanding statement, if the database supports that operation.
voidclearBatch()

This method clears out any SQL statements that have been populated in the current batch.
voidclearWarnings()

This method clears any SQL warnings that have been attached to this statement.
voidclose()

This method closes the statement and frees any associated resources.
booleanexecute(java.lang.String sql)

This method executes an arbitrary SQL statement of any time.
booleanexecute(java.lang.String sql, int autoGeneratedKeys)

booleanexecute(java.lang.String sql, int[] columnIndexes)

booleanexecute(java.lang.String sql, java.lang.String[] columnNames)

int[]executeBatch()

This method executes the SQL batch and returns an array of update counts - one for each SQL statement in the batch - ordered in the same order the statements were added to the batch.
java.sql.ResultSetexecuteQuery(java.lang.String sql)

This method executes the specified SQL SELECT statement and returns a (possibly empty) ResultSet with the results of the query.
intexecuteUpdate(java.lang.String sql)

This method executes the specified SQL INSERT, UPDATE, or DELETE statement and returns the number of rows affected, which may be 0.
intexecuteUpdate(java.lang.String sql, int autoGeneratedKeys)

intexecuteUpdate(java.lang.String sql, int[] columnIndexes)

intexecuteUpdate(java.lang.String sql, java.lang.String[] columnNames)

java.sql.ConnectiongetConnection()

This method returns the Connection instance that was used to create this object.
intgetFetchDirection()

This method returns the current direction that the driver thinks the result set will be accessed int.
intgetFetchSize()

This method returns the number of rows the driver believes should be fetched from the database at a time.
java.sql.ResultSetgetGeneratedKeys()

intgetMaxFieldSize()

This method returns the maximum length of any column value in bytes.
intgetMaxRows()

This method returns the maximum possible number of rows in a result set.
booleangetMoreResults()

This method advances the result set pointer to the next result set, which can then be retrieved using getResultSet
booleangetMoreResults(int current)

intgetQueryTimeout()

The method returns the number of seconds a statement may be in process before timing out.
java.sql.ResultSetgetResultSet()

This method returns the result set of the SQL statement that was executed.
intgetResultSetConcurrency()

This method returns the concurrency type of the result set for this statement.
intgetResultSetHoldability()

intgetResultSetType()

This method returns the result set type for this statement.
intgetUpdateCount()

This method returns the update count of the SQL statement that was executed.
java.sql.SQLWarninggetWarnings()

This method returns the first SQL warning attached to this statement.
voidsetCursorName(java.lang.String name)

This method sets the cursor name that will be used by the result set.
voidsetEscapeProcessing(boolean enable)

This method sets the local escape processing mode on or off.
voidsetFetchDirection(int direction)

This method informs the driver which direction the result set will be accessed in.
voidsetFetchSize(int rows)

This method informs the driver how many rows it should fetch from the database at a time.
voidsetMaxFieldSize(int max)

This method sets the limit for the maximum length of any column in bytes.
voidsetMaxRows(int max)

This method sets the maximum number of rows that can be present in a result set.
voidsetQueryTimeout(int seconds)

This method sets the number of seconds a statement may be in process before timing out.

Field Details

CLOSE_ALL_RESULTS

public static final int CLOSE_ALL_RESULTS


CLOSE_CURRENT_RESULT

public static final int CLOSE_CURRENT_RESULT

This interface provides a mechanism for executing SQL statements.

Author:

EXECUTE_FAILED

public static final int EXECUTE_FAILED


KEEP_CURRENT_RESULT

public static final int KEEP_CURRENT_RESULT


NO_GENERATED_KEYS

public static final int NO_GENERATED_KEYS


RETURN_GENERATED_KEYS

public static final int RETURN_GENERATED_KEYS


SUCCESS_NO_INFO

public static final int SUCCESS_NO_INFO


Method Details

addBatch

public void addBatch(java.lang.String sql)

This method adds a SQL statement to a SQL batch. A driver is not required to implement this method.

Parameters:

Throws:


cancel

public void cancel()

This method cancels an outstanding statement, if the database supports that operation.

Throws:


clearBatch

public void clearBatch()

This method clears out any SQL statements that have been populated in the current batch. A driver is not required to implement this method.

Throws:


clearWarnings

public void clearWarnings()

This method clears any SQL warnings that have been attached to this statement.

Throws:


close

public void close()

This method closes the statement and frees any associated resources.

Throws:


execute

public boolean execute(java.lang.String sql)

This method executes an arbitrary SQL statement of any time. The methods getResultSet, getMoreResults and getUpdateCount retrieve the results.

Parameters:

Returns:

Throws:


execute

public boolean execute(java.lang.String sql, int autoGeneratedKeys)

Since:Parameters:


execute

public boolean execute(java.lang.String sql, int[] columnIndexes)

Since:Parameters:


execute

public boolean execute(java.lang.String sql, java.lang.String[] columnNames)

Since:Parameters:


executeBatch

public int[] executeBatch()

This method executes the SQL batch and returns an array of update counts - one for each SQL statement in the batch - ordered in the same order the statements were added to the batch. A driver is not required to implement this method.

Returns:

Throws:


executeQuery

public ResultSet executeQuery(java.lang.String sql)

This method executes the specified SQL SELECT statement and returns a (possibly empty) ResultSet with the results of the query.

Parameters:

Returns:

Throws:


executeUpdate

public int executeUpdate(java.lang.String sql)

This method executes the specified SQL INSERT, UPDATE, or DELETE statement and returns the number of rows affected, which may be 0.

Parameters:

Returns:

Throws:


executeUpdate

public int executeUpdate(java.lang.String sql, int autoGeneratedKeys)

Since:Parameters:


executeUpdate

public int executeUpdate(java.lang.String sql, int[] columnIndexes)

Since:Parameters:


executeUpdate

public int executeUpdate(java.lang.String sql, java.lang.String[] columnNames)

Since:Parameters:


getConnection

public Connection getConnection()

This method returns the Connection instance that was used to create this object.

Returns:

Throws:


getFetchDirection

public int getFetchDirection()

This method returns the current direction that the driver thinks the result set will be accessed int.

Returns:

Throws:


getFetchSize

public int getFetchSize()

This method returns the number of rows the driver believes should be fetched from the database at a time.

Returns:

Throws:


getGeneratedKeys

public ResultSet getGeneratedKeys()

Since:

getMaxFieldSize

public int getMaxFieldSize()

This method returns the maximum length of any column value in bytes.

Returns:

Throws:


getMaxRows

public int getMaxRows()

This method returns the maximum possible number of rows in a result set.

Returns:

Throws:


getMoreResults

public boolean getMoreResults()

This method advances the result set pointer to the next result set, which can then be retrieved using getResultSet

Returns:

Throws:

See Also:


getMoreResults

public boolean getMoreResults(int current)

Since:Parameters:


getQueryTimeout

public int getQueryTimeout()

The method returns the number of seconds a statement may be in process before timing out. A value of 0 means there is no timeout.

Returns:

Throws:


getResultSet

public ResultSet getResultSet()

This method returns the result set of the SQL statement that was executed. This should be called only once per result set returned.

Returns:

Throws:

See Also:


getResultSetConcurrency

public int getResultSetConcurrency()

This method returns the concurrency type of the result set for this statement. This will be one of the concurrency types defined in ResultSet.

Returns:

Throws:

See Also:


getResultSetHoldability

public int getResultSetHoldability()

Since:

getResultSetType

public int getResultSetType()

This method returns the result set type for this statement. This will be one of the result set types defined in ResultSet.

Returns:

Throws:

See Also:


getUpdateCount

public int getUpdateCount()

This method returns the update count of the SQL statement that was executed. This should be called only once per executed SQL statement.

Returns:

Throws:

See Also:


getWarnings

public SQLWarning getWarnings()

This method returns the first SQL warning attached to this statement. Subsequent warnings will be chained to this one.

Returns:

Throws:


setCursorName

public void setCursorName(java.lang.String name)

This method sets the cursor name that will be used by the result set.

Parameters:

Throws:


setEscapeProcessing

public void setEscapeProcessing(boolean enable)

This method sets the local escape processing mode on or off. The default value is on.

Parameters:

Throws:


setFetchDirection

public void setFetchDirection(int direction)

This method informs the driver which direction the result set will be accessed in.

Parameters:

Throws:


setFetchSize

public void setFetchSize(int rows)

This method informs the driver how many rows it should fetch from the database at a time.

Parameters:

Throws:


setMaxFieldSize

public void setMaxFieldSize(int max)

This method sets the limit for the maximum length of any column in bytes.

Parameters:

Throws:


setMaxRows

public void setMaxRows(int max)

This method sets the maximum number of rows that can be present in a result set.

Parameters:

Throws:


setQueryTimeout

public void setQueryTimeout(int seconds)

This method sets the number of seconds a statement may be in process before timing out. A value of 0 means there is no timeout.

Parameters:

Throws: