Class org.gjt.mm.mysql.Statement
java.lang.Object
|
+--org.gjt.mm.mysql.Statement
- Subclasses:
- PreparedStatement
- public class Statement
- extends java.lang.Object
- implements java.sql.Statement
Method Summary
|
void
|
cancel()
Cancel can be used by one thread to cancel a statement that
is being executed by another thread. |
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. |
java.sql.ResultSet
|
executeQuery(java.lang.String Sql)
Execute a SQL statement that retruns a single ResultSet |
boolean
|
execute(java.lang.String Sql)
Execute a SQL statement that may return multiple results. |
int
|
executeUpdate(java.lang.String Sql)
Execute a SQL INSERT, UPDATE or DELETE statement. |
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
|
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
|
setMaxFieldSize(int max)
Sets the maxFieldSize |
void
|
setMaxRows(int max)
Set the maximum number of rows |
void
|
setQueryTimeout(int seconds)
Sets the queryTimeout limit |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notifyAll, notify, toString, wait, wait, wait |
Statement
public Statement(Connection C)
- Constructor for a Statement. It simply sets the connection
that created us.
- Parameters:
c
- the Connection instantation that creates us
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:
- executeQuery(java.lang.String) in interface java.sql.Statement
- Parameters:
Sql
- typically a static SQL SELECT statement- Returns:
- a ResulSet that contains the data produced by the query
- Throws:
- java.sql.SQLException - if a database access error occurs
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
Any IDs generated for AUTO_INCREMENT fields can be retrieved
by looking through the SQLWarning chain of this statement
for warnings of the form "LAST_INSERTED_ID = 'some number',
COMMAND = 'your sql'".
- Specified by:
- executeUpdate(java.lang.String) in interface java.sql.Statement
- Parameters:
Sql
- a SQL statement- Returns:
- either a row count, or 0 for SQL commands
- Throws:
- java.sql.SQLException - if a database access error occurs
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:
- close() in interface java.sql.Statement
- Throws:
- java.sql.SQLException - if a database access error occurs (why?)
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:
- getMaxFieldSize() in interface java.sql.Statement
- Returns:
- the current max column size limit; zero means unlimited
- Throws:
- java.sql.SQLException - if a database access error occurs
setMaxFieldSize
public void setMaxFieldSize(int max)
throws java.sql.SQLException
- Sets the maxFieldSize
- Specified by:
- setMaxFieldSize(int) in interface java.sql.Statement
- Parameters:
max
- the new max column size limit; zero means unlimited- Throws:
- java.sql.SQLException - if size exceeds buffer size
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:
- getMaxRows() in interface java.sql.Statement
- Returns:
- the current maximum row limit; zero means unlimited
- Throws:
- java.sql.SQLException - if a database access error occurs
setMaxRows
public void setMaxRows(int max)
throws java.sql.SQLException
- Set the maximum number of rows
- Specified by:
- setMaxRows(int) in interface java.sql.Statement
- Parameters:
max
- the new max rows limit; zero means unlimited- Throws:
- java.sql.SQLException - if a database access error occurs
- See Also:
- getMaxRows
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:
- setEscapeProcessing(boolean) in interface java.sql.Statement
- Parameters:
enable
- true to enable; false to disable- Throws:
- java.sql.SQLException - if a database access error occurs
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:
- getQueryTimeout() in interface java.sql.Statement
- Returns:
- the current query timeout limit in seconds; 0 = unlimited
- Throws:
- java.sql.SQLException - if a database access error occurs
setQueryTimeout
public void setQueryTimeout(int seconds)
throws java.sql.SQLException
- Sets the queryTimeout limit
- Specified by:
- setQueryTimeout(int) in interface java.sql.Statement
- Parameters:
seconds
- - the new query timeout limit in seconds- Throws:
- java.sql.SQLException - if a database access error occurs
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 this driver
is synchronous, 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.)
- Specified by:
- cancel() in interface java.sql.Statement
- Throws:
- java.sql.SQLException - only because thats the spec.
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:
- getWarnings() in interface java.sql.Statement
- Returns:
- the first SQLWarning on null
- Throws:
- java.sql.SQLException - if a database access error occurs
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:
- clearWarnings() in interface java.sql.Statement
- Throws:
- java.sql.SQLException - if a database access error occurs (why?)
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: This MySQL driver does not support cursors.
- Specified by:
- setCursorName(java.lang.String) in interface java.sql.Statement
- Parameters:
name
- the new cursor name- Throws:
- java.sql.SQLException - if a database access error occurs
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:
- execute(java.lang.String) in interface java.sql.Statement
- Parameters:
sql
- any SQL statement- Returns:
- true if the next result is a ResulSet, false if it is
an update count or there are no more results
- Throws:
- java.sql.SQLException - if a database access error occurs
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:
- getResultSet() in interface java.sql.Statement
- Returns:
- the current result set; null if there are no more
- Throws:
- java.sql.SQLException - if a database access error occurs (why?)
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:
- getUpdateCount() in interface java.sql.Statement
- Returns:
- the current result as an update count.
- Throws:
- java.sql.SQLException - if a database access error occurs
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:
- getMoreResults() in interface java.sql.Statement
- Returns:
- true if the next ResultSet is valid
- Throws:
- java.sql.SQLException - if a database access error occurs