|
|||||||||
| Home >> All >> postgresql >> [ jdbc2 overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
postgresql.jdbc2
Class Statement

java.lang.Objectpostgresql.jdbc2.Statement
- All Implemented Interfaces:
- java.sql.Statement
- Direct Known Subclasses:
- PreparedStatement
- public class Statement
- extends java.lang.Object
- implements java.sql.Statement
- extends java.lang.Object
A Statement object is used for executing a static SQL statement and obtaining the results produced by it.
Only one ResultSet per Statement can be open at any point in time. Therefore, if the reading of one ResultSet is interleaved with the reading of another, each must have been generated by different Statements. All statement execute methods implicitly close a statement's current ResultSet if an open one exists.
| Field Summary | |
private java.util.Vector |
batch
|
(package private) Connection |
connection
|
(package private) boolean |
escapeProcessing
|
(package private) java.sql.ResultSet |
result
|
(package private) int |
timeout
|
(package private) java.sql.SQLWarning |
warnings
|
| 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 | |
Statement(Connection c)
Constructor for a Statement. |
|
| Method Summary | |
void |
addBatch(java.lang.String sql)
This method adds a SQL statement to a SQL batch. |
void |
cancel()
Cancel can be used by one thread to cancel a statement that is being executed by another thread. |
void |
clearBatch()
This method clears out any SQL statements that have been populated in the current batch. |
void |
clearWarnings()
After this call, getWarnings returns null until a new warning is reported for this Statement. |
void |
close()
In many cases, it is desirable to immediately release a Statement's database and JDBC resources instead of waiting for this to happen when it is automatically closed. |
boolean |
execute(java.lang.String sql)
Execute a SQL statement that may return multiple results. |
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.ResultSet |
executeQuery(java.lang.String sql)
Execute a SQL statement that retruns a single ResultSet |
int |
executeUpdate(java.lang.String sql)
Execute a SQL INSERT, UPDATE or DELETE statement. |
java.sql.Connection |
getConnection()
This method returns the Connection instance that was
used to create this object. |
int |
getFetchDirection()
This method returns the current direction that the driver thinks the result set will be accessed int. |
int |
getFetchSize()
This method returns the number of rows the driver believes should be fetched from the database at a time. |
int |
getKeysetSize()
|
int |
getMaxFieldSize()
The maxFieldSize limit (in bytes) is the maximum amount of data returned for any column value; it only applies to BINARY, VARBINARY, LONGVARBINARY, CHAR, VARCHAR and LONGVARCHAR columns. |
int |
getMaxRows()
The maxRows limit is set to limit the number of rows that any ResultSet can contain. |
boolean |
getMoreResults()
getMoreResults moves to a Statement's next result. |
int |
getQueryTimeout()
The queryTimeout limit is the number of seconds the driver will wait for a Statement to execute. |
java.sql.ResultSet |
getResultSet()
getResultSet returns the current result as a ResultSet. |
int |
getResultSetConcurrency()
This method returns the concurrency type of the result set for this statement. |
int |
getResultSetType()
This method returns the result set type for this statement. |
java.lang.String |
getResultStatusString()
Returns the status message from the current Result. |
int |
getUpdateCount()
getUpdateCount returns the current result as an update count, if the result is a ResultSet or there are no more results, -1 is returned. |
java.sql.SQLWarning |
getWarnings()
The first warning reported by calls on this Statement is returned. |
void |
setCursorName(java.lang.String name)
setCursorName defines the SQL cursor name that will be used by subsequent execute methods. |
void |
setEscapeProcessing(boolean enable)
If escape scanning is on (the default), the driver will do escape substitution before sending the SQL to the database. |
void |
setFetchDirection(int direction)
This method informs the driver which direction the result set will be accessed in. |
void |
setFetchSize(int rows)
This method informs the driver how many rows it should fetch from the database at a time. |
void |
setKeysetSize(int keys)
|
void |
setMaxFieldSize(int max)
Sets the maxFieldSize - NOT! - We throw an SQLException just to inform them to stop doing this. |
void |
setMaxRows(int max)
Set the maximum number of rows |
void |
setQueryTimeout(int seconds)
Sets the queryTimeout limit |
void |
setResultSetConcurrency(int value)
|
void |
setResultSetType(int value)
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface java.sql.Statement |
execute, execute, execute, executeUpdate, executeUpdate, executeUpdate, getGeneratedKeys, getMoreResults, getResultSetHoldability |
| Field Detail |
connection
Connection connection
result
java.sql.ResultSet result
warnings
java.sql.SQLWarning warnings
timeout
int timeout
escapeProcessing
boolean escapeProcessing
batch
private java.util.Vector batch
| Constructor Detail |
Statement
public Statement(Connection c)
- Constructor for a Statement. It simply sets the connection
that created us.
| Method Detail |
executeQuery
public java.sql.ResultSet executeQuery(java.lang.String sql) throws java.sql.SQLException
- Execute a SQL statement that retruns a single ResultSet
- Specified by:
executeQueryin interfacejava.sql.Statement
executeUpdate
public int executeUpdate(java.lang.String sql) throws java.sql.SQLException
- Execute a SQL INSERT, UPDATE or DELETE statement. In addition
SQL statements that return nothing such as SQL DDL statements
can be executed
- Specified by:
executeUpdatein interfacejava.sql.Statement
close
public void close()
throws java.sql.SQLException
- In many cases, it is desirable to immediately release a
Statement's database and JDBC resources instead of waiting
for this to happen when it is automatically closed. The
close method provides this immediate release.
Note: A Statement is automatically closed when it is garbage collected. When a Statement is closed, its current ResultSet, if one exists, is also closed.
- Specified by:
closein interfacejava.sql.Statement
getMaxFieldSize
public int getMaxFieldSize()
throws java.sql.SQLException
- The maxFieldSize limit (in bytes) is the maximum amount of
data returned for any column value; it only applies to
BINARY, VARBINARY, LONGVARBINARY, CHAR, VARCHAR and LONGVARCHAR
columns. If the limit is exceeded, the excess data is silently
discarded.
- Specified by:
getMaxFieldSizein interfacejava.sql.Statement
setMaxFieldSize
public void setMaxFieldSize(int max)
throws java.sql.SQLException
- Sets the maxFieldSize - NOT! - We throw an SQLException just
to inform them to stop doing this.
- Specified by:
setMaxFieldSizein interfacejava.sql.Statement
getMaxRows
public int getMaxRows()
throws java.sql.SQLException
- The maxRows limit is set to limit the number of rows that
any ResultSet can contain. If the limit is exceeded, the
excess rows are silently dropped.
- Specified by:
getMaxRowsin interfacejava.sql.Statement
setMaxRows
public void setMaxRows(int max)
throws java.sql.SQLException
- Set the maximum number of rows
- Specified by:
setMaxRowsin interfacejava.sql.Statement
setEscapeProcessing
public void setEscapeProcessing(boolean enable)
throws java.sql.SQLException
- If escape scanning is on (the default), the driver will do escape
substitution before sending the SQL to the database.
- Specified by:
setEscapeProcessingin interfacejava.sql.Statement
getQueryTimeout
public int getQueryTimeout()
throws java.sql.SQLException
- The queryTimeout limit is the number of seconds the driver
will wait for a Statement to execute. If the limit is
exceeded, a SQLException is thrown.
- Specified by:
getQueryTimeoutin interfacejava.sql.Statement
setQueryTimeout
public void setQueryTimeout(int seconds)
throws java.sql.SQLException
- Sets the queryTimeout limit
- Specified by:
setQueryTimeoutin interfacejava.sql.Statement
cancel
public void cancel()
throws java.sql.SQLException
- Cancel can be used by one thread to cancel a statement that
is being executed by another thread. However, PostgreSQL is
a sync. sort of thing, so this really has no meaning - we
define it as a no-op (i.e. you can't cancel, but there is no
error if you try.)
6.4 introduced a cancel operation, but we have not implemented it
yet. Sometime before 6.5, this method will be implemented.
- Specified by:
cancelin interfacejava.sql.Statement
getWarnings
public java.sql.SQLWarning getWarnings() throws java.sql.SQLException
- The first warning reported by calls on this Statement is
returned. A Statement's execute methods clear its SQLWarning
chain. Subsequent Statement warnings will be chained to this
SQLWarning.
The Warning chain is automatically cleared each time a statement is (re)executed.
Note: If you are processing a ResultSet then any warnings associated with ResultSet reads will be chained on the ResultSet object.
- Specified by:
getWarningsin interfacejava.sql.Statement
clearWarnings
public void clearWarnings()
throws java.sql.SQLException
- After this call, getWarnings returns null until a new warning
is reported for this Statement.
- Specified by:
clearWarningsin interfacejava.sql.Statement
setCursorName
public void setCursorName(java.lang.String name) throws java.sql.SQLException
- setCursorName defines the SQL cursor name that will be used by
subsequent execute methods. This name can then be used in SQL
positioned update/delete statements to identify the current row
in the ResultSet generated by this statement. If a database
doesn't support positioned update/delete, this method is a
no-op.
Note: By definition, positioned update/delete execution must be done by a different Statement than the one which generated the ResultSet being used for positioning. Also, cursor names must be unique within a Connection.
We throw an additional constriction. There can only be one cursor active at any one time.
- Specified by:
setCursorNamein interfacejava.sql.Statement
execute
public boolean execute(java.lang.String sql) throws java.sql.SQLException
- Execute a SQL statement that may return multiple results. We
don't have to worry about this since we do not support multiple
ResultSets. You can use getResultSet or getUpdateCount to
retrieve the result.
- Specified by:
executein interfacejava.sql.Statement
getResultSet
public java.sql.ResultSet getResultSet() throws java.sql.SQLException
- getResultSet returns the current result as a ResultSet. It
should only be called once per result.
- Specified by:
getResultSetin interfacejava.sql.Statement
getUpdateCount
public int getUpdateCount()
throws java.sql.SQLException
- getUpdateCount returns the current result as an update count,
if the result is a ResultSet or there are no more results, -1
is returned. It should only be called once per result.
- Specified by:
getUpdateCountin interfacejava.sql.Statement
getMoreResults
public boolean getMoreResults()
throws java.sql.SQLException
- getMoreResults moves to a Statement's next result. If it returns
true, this result is a ResulSet.
- Specified by:
getMoreResultsin interfacejava.sql.Statement
getResultStatusString
public java.lang.String getResultStatusString()
- Returns the status message from the current Result.
This is used internally by the driver.
addBatch
public void addBatch(java.lang.String sql) throws java.sql.SQLException
- Description copied from interface:
java.sql.Statement - This method adds a SQL statement to a SQL batch. A driver is not
required to implement this method.
- Specified by:
addBatchin interfacejava.sql.Statement
clearBatch
public void clearBatch()
throws java.sql.SQLException
- Description copied from interface:
java.sql.Statement - This method clears out any SQL statements that have been populated in
the current batch. A driver is not required to implement this method.
- Specified by:
clearBatchin interfacejava.sql.Statement
executeBatch
public int[] executeBatch()
throws java.sql.SQLException
- Description copied from interface:
java.sql.Statement - 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.
- Specified by:
executeBatchin interfacejava.sql.Statement
getConnection
public java.sql.Connection getConnection() throws java.sql.SQLException
- Description copied from interface:
java.sql.Statement - This method returns the
Connectioninstance that was used to create this object.- Specified by:
getConnectionin interfacejava.sql.Statement
getFetchDirection
public int getFetchDirection()
throws java.sql.SQLException
- Description copied from interface:
java.sql.Statement - This method returns the current direction that the driver thinks the
result set will be accessed int.
- Specified by:
getFetchDirectionin interfacejava.sql.Statement
getFetchSize
public int getFetchSize()
throws java.sql.SQLException
- Description copied from interface:
java.sql.Statement - This method returns the number of rows the driver believes should be
fetched from the database at a time.
- Specified by:
getFetchSizein interfacejava.sql.Statement
getKeysetSize
public int getKeysetSize()
throws java.sql.SQLException
getResultSetConcurrency
public int getResultSetConcurrency()
throws java.sql.SQLException
- Description copied from interface:
java.sql.Statement - This method returns the concurrency type of the result set for this
statement. This will be one of the concurrency types defined in
ResultSet.- Specified by:
getResultSetConcurrencyin interfacejava.sql.Statement
getResultSetType
public int getResultSetType()
throws java.sql.SQLException
- Description copied from interface:
java.sql.Statement - This method returns the result set type for this statement. This will
be one of the result set types defined in
ResultSet.- Specified by:
getResultSetTypein interfacejava.sql.Statement
setFetchDirection
public void setFetchDirection(int direction)
throws java.sql.SQLException
- Description copied from interface:
java.sql.Statement - This method informs the driver which direction the result set will
be accessed in.
- Specified by:
setFetchDirectionin interfacejava.sql.Statement
setFetchSize
public void setFetchSize(int rows)
throws java.sql.SQLException
- Description copied from interface:
java.sql.Statement - This method informs the driver how many rows it should fetch from the
database at a time.
- Specified by:
setFetchSizein interfacejava.sql.Statement
setKeysetSize
public void setKeysetSize(int keys)
throws java.sql.SQLException
setResultSetConcurrency
public void setResultSetConcurrency(int value)
throws java.sql.SQLException
setResultSetType
public void setResultSetType(int value)
throws java.sql.SQLException
|
|||||||||
| Home >> All >> postgresql >> [ jdbc2 overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC
postgresql.jdbc2.Statement