Class com.imaginary.sql.msql.MsqlStatement
java.lang.Object
|
+--com.imaginary.sql.msql.MsqlStatement
- Subclasses:
- MsqlPreparedStatement
- public class MsqlStatement
- extends java.lang.Object
- implements java.sql.Statement
The MsqlStatement class implements the JDBC Statement interface.
This class represents any SQL statement. This class does minimal
locking designed simply around its asynchronous result set processing.
Applications should make sure either that multiple threads do not
share a Statement or that they do careful synchronization. When
synchronizing on the statement, be careful not to grab any long-held
locks on it or you might prevent data loading.
Last modified $Date: 1999/07/06 05:56:14 $
- Version:
- $Revision: 1.6 $
- Author:
- George Reese (borg@imaginary.com)
Method Summary
|
void
|
addBatch(java.lang.String sql)
Adds a SQL string to the list of SQL statements that should be
executed as part of the next batch operation. |
void
|
cancel()
mSQL statement processing must run through to its natural conclusion.
|
void
|
clearBatch()
Clears the batch list. |
void
|
clearWarnings()
mSQL does not generated any warnings, so this method is always a
NO-OP. |
void
|
close()
Closes the statement. |
int[]
|
executeBatch()
Executes the batch statements added to this Statement via
addBatch(). |
boolean
|
execute(java.lang.String sql)
Sends some random SQL to the database |
java.sql.ResultSet
|
executeQuery(java.lang.String sql)
Executes a query and returns a result set matching the type and
concurrency characteristics of this Statement. |
int
|
executeUpdate(java.lang.String sql)
Sends an UPDATE to the database. |
java.sql.Connection
|
getConnection()
This method has changed between mSQL-JDBC 1.x and 2.x to reflect
the fact that this is actually a JDBC method as of JDBC 2.0. This
change should have no effect on even the most poorly designed
users of mSQL-JDBC. |
java.lang.String
|
getEncoding()
|
int
|
getFetchDirection()
|
int
|
getFetchSize()
mSQL-JDBC always fetches all rows. |
int
|
getMaxFieldSize()
|
int
|
getMaxRows()
|
boolean
|
getMoreResults()
|
int
|
getQueryTimeout()
The query timeout is the number of seconds a statement should
wait before aborting the execution of a statement. |
int
|
getResultSetConcurrency()
JDBC 2.0 result set concurrency. |
java.sql.ResultSet
|
getResultSet()
Call this method after using the execute() method to send SQL
to the database and finding that a result set was created.
|
int
|
getResultSetType()
JDBC 2.0 result set type. |
int
|
getUpdateCount()
Call this method after using the execute() method to send SQL
to the database and finding that rows were updated. |
java.sql.SQLWarning
|
getWarnings()
mSQL does not generate warnings, so this method always returns null. |
void
|
setCursorName(java.lang.String unused)
This method is required by the JDBC 2.0 specification but is not
a supported feature of mSQL. It is therefore a NO-OP as specified
by the JDBC 2.0 specification. |
void
|
setEscapeProcessing(boolean enable)
Toggles on and off escape substitution before sending SQL to the
database. |
void
|
setFetchDirection(int dir)
Provide a hint to mSQL-JDBC as to which direction results should
be fetched int. |
void
|
setFetchSize(int unused)
This is a NO-OP since no matter what you suggest, mSQL-JDBC
is forced by the mSQL network protocol to download all rows. |
void
|
setMaxFieldSize(int max)
Sets the maximum field size for certain data types. |
void
|
setMaxRows(int max)
Sets the maximum number of rows to be returned by results generated
by this statement. |
void
|
setQueryTimeout(int unused)
This is a NO-OP since mSQL queries must run to their conclusion. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notifyAll, notify, toString, wait, wait, wait |
log
protected MsqlLog log
addBatch
public void addBatch(java.lang.String sql)
throws java.sql.SQLException
- Adds a SQL string to the list of SQL statements that should be
executed as part of the next batch operation. These statements
should only ever be updates.
- Specified by:
- addBatch(java.lang.String) in interface java.sql.Statement
- Parameters:
sql
- the SQL statement to be added to the batch- Throws:
- java.sql.SQLException - this is never thrown
cancel
public void cancel()
throws java.sql.SQLException
- mSQL statement processing must run through to its natural conclusion.
This method thus simply waits until it is safe to use this Statement
for other things. In other words, its behaviour is consistent with
JDBC compliant drivers but it is not exactly what the JDBC authors had
in mind for a cancel operation.
- Specified by:
- cancel() in interface java.sql.Statement
- Throws:
- java.sql.SQLException - this is never thrown
clearBatch
public void clearBatch()
throws java.sql.SQLException
- Clears the batch list.
- Specified by:
- clearBatch() in interface java.sql.Statement
- Throws:
- java.sql.SQLException - this is never thrown
clearWarnings
public void clearWarnings()
throws java.sql.SQLException
- mSQL does not generated any warnings, so this method is always a
NO-OP.
- Specified by:
- clearWarnings() in interface java.sql.Statement
- Throws:
- java.sql.SQLException - this is never thrown
close
public void close()
throws java.sql.SQLException
- Closes the statement. This method will wait until all results
have been loaded from the database in order to avoid screwing up
the mSQL protocol.
- Specified by:
- close() in interface java.sql.Statement
- Throws:
- java.sql.SQLException - this should never actually be thrown
execute
public boolean execute(java.lang.String sql)
throws java.sql.SQLException
- Sends some random SQL to the database
- Specified by:
- execute(java.lang.String) in interface java.sql.Statement
- Parameters:
sql
- the SQL to be sent to the database- Returns:
- true if the SQL produced a result set
- Throws:
- java.sql.SQLException - an error occurred talking to the
database
executeBatch
public int[] executeBatch()
throws java.sql.SQLException
- Executes the batch statements added to this Statement via
addBatch().
- Specified by:
- executeBatch() in interface java.sql.Statement
- Returns:
- an array of update counts for each batch
- Throws:
- java.sql.SQLException - one or more of the batch processes
failed
executeQuery
public java.sql.ResultSet executeQuery(java.lang.String sql)
throws java.sql.SQLException
- Executes a query and returns a result set matching the type and
concurrency characteristics of this Statement.
- Specified by:
- executeQuery(java.lang.String) in interface java.sql.Statement
- Parameters:
sql
- the SQL to send to the database- Returns:
- a ResultSet matching the query
- Throws:
- java.sql.SQLException - an erroroccurred talking to the
database
executeUpdate
public int executeUpdate(java.lang.String sql)
throws java.sql.SQLException
- Sends an UPDATE to the database.
- Specified by:
- executeUpdate(java.lang.String) in interface java.sql.Statement
- Parameters:
sql
- the UPDATE SQL- Returns:
- the numberof affected rows
- Throws:
- java.sql.SQLException - an error occurred talking to the
database
getConnection
public java.sql.Connection getConnection()
- This method has changed between mSQL-JDBC 1.x and 2.x to reflect
the fact that this is actually a JDBC method as of JDBC 2.0. This
change should have no effect on even the most poorly designed
users of mSQL-JDBC.
- Specified by:
- getConnection() in interface java.sql.Statement
- Returns:
- the MsqlConnection that owns this Statement
getEncoding
public java.lang.String getEncoding()
- Returns:
- the encoding for this application
getFetchDirection
public int getFetchDirection()
throws java.sql.SQLException
- Description copied from interface:
- Specified by:
- getFetchDirection() in interface java.sql.Statement
- Returns:
- the direction in which results might be fetched
- Throws:
- java.sql.SQLException - this is never thrown
getFetchSize
public int getFetchSize()
throws java.sql.SQLException
- mSQL-JDBC always fetches all rows. This is required by the mSQL
network protocol and cannot be modified.
- Specified by:
- getFetchSize() in interface java.sql.Statement
- Returns:
- 0
- Throws:
- java.sql.SQLException - this is never thrown
getMaxFieldSize
public int getMaxFieldSize()
throws java.sql.SQLException
- Description copied from interface:
- Specified by:
- getMaxFieldSize() in interface java.sql.Statement
- Returns:
- the maximum field size allowed for BINARY, VARBINARY,
LONGVARBINARY, CHAR, VARCHAR, and LONGVARCHAR columns
- Throws:
- java.sql.SQLException - this is never thrown
getMaxRows
public int getMaxRows()
throws java.sql.SQLException
- Description copied from interface:
- Specified by:
- getMaxRows() in interface java.sql.Statement
- Returns:
- the maximum number of rows for a result set created by
this statement
- Throws:
- java.sql.SQLException - this is never thrown
getMoreResults
public boolean getMoreResults()
throws java.sql.SQLException
- Description copied from interface:
- Specified by:
- getMoreResults() in interface java.sql.Statement
- Returns:
- true if there are more results to process
- Throws:
- java.sql.SQLException - this will not be thrown
getQueryTimeout
public int getQueryTimeout()
throws java.sql.SQLException
- The query timeout is the number of seconds a statement should
wait before aborting the execution of a statement. If the limit
is encountered, processing ends and an exception is thrown.
- Specified by:
- getQueryTimeout() in interface java.sql.Statement
- Returns:
- the query timeout
- Throws:
- java.sql.SQLException - this is never thrown
getResultSet
public java.sql.ResultSet getResultSet()
throws java.sql.SQLException
- Call this method after using the execute() method to send SQL
to the database and finding that a result set was created.
Watch your synchronization in this event. If you call execute()
and then another thread uses this Statement to issue a new query
before you call getResultSet(), you will find no results.
- Specified by:
- getResultSet() in interface java.sql.Statement
- Returns:
- a result set matching the most recent query
- Throws:
- java.sql.SQLException - no result set was waiting
getResultSetConcurrency
public int getResultSetConcurrency()
throws java.sql.SQLException
- JDBC 2.0 result set concurrency. This determines whether or
not a result set generated by this statement can be updated in
place.
- Specified by:
- getResultSetConcurrency() in interface java.sql.Statement
- Returns:
- the result set concurrency
- Throws:
- java.sql.SQLException - this is never thrown
getResultSetType
public int getResultSetType()
throws java.sql.SQLException
- JDBC 2.0 result set type. This is the kind of result set that will
be generated by this statement.
- Specified by:
- getResultSetType() in interface java.sql.Statement
- Returns:
- the result set type
- Throws:
- java.sql.SQLException - this is never actually thrown
getUpdateCount
public int getUpdateCount()
throws java.sql.SQLException
- Call this method after using the execute() method to send SQL
to the database and finding that rows were updated. This method
will tell you how many rows were modified.
Watch your synchronization in this event. If you call execute()
and then another thread uses this Statement to issue new SQL
before you call getUpdateCount(), you will get a meaningless answer.
- Specified by:
- getUpdateCount() in interface java.sql.Statement
- Returns:
- the number of rows affected by the last SQL sent to execute()
getWarnings
public final java.sql.SQLWarning getWarnings()
throws java.sql.SQLException
- mSQL does not generate warnings, so this method always returns null.
- Specified by:
- getWarnings() in interface java.sql.Statement
- Returns:
- null
- Throws:
- java.sql.SQLException - this is never thrown
setQueryTimeout
public void setQueryTimeout(int unused)
throws java.sql.SQLException
- This is a NO-OP since mSQL queries must run to their conclusion.
- Specified by:
- setQueryTimeout(int) in interface java.sql.Statement
- Parameters:
unused
- the number of seconds the Statement should wait- Throws:
- java.sql.SQLException - this is never thrown
setCursorName
public void setCursorName(java.lang.String unused)
throws java.sql.SQLException
- This method is required by the JDBC 2.0 specification but is not
a supported feature of mSQL. It is therefore a NO-OP as specified
by the JDBC 2.0 specification.
- Specified by:
- setCursorName(java.lang.String) in interface java.sql.Statement
- Parameters:
unused
- the name of the cursor- Throws:
- java.sql.SQLException - this is never thrown
setEscapeProcessing
public void setEscapeProcessing(boolean enable)
throws java.sql.SQLException
- Toggles on and off escape substitution before sending SQL to the
database. The driver does not yet support this.
- Specified by:
- setEscapeProcessing(boolean) in interface java.sql.Statement
- Parameters:
enable
- indicate whether to enable or disable escape processing- Throws:
- java.sql.SQLException - escape processing not supported
setFetchDirection
public void setFetchDirection(int dir)
throws java.sql.SQLException
- Provide a hint to mSQL-JDBC as to which direction results should
be fetched int.
- Specified by:
- setFetchDirection(int) in interface java.sql.Statement
- Parameters:
dir
- the direction- Throws:
- java.sql.SQLException - this is never thrown
setFetchSize
public void setFetchSize(int unused)
throws java.sql.SQLException
- This is a NO-OP since no matter what you suggest, mSQL-JDBC
is forced by the mSQL network protocol to download all rows.
- Specified by:
- setFetchSize(int) in interface java.sql.Statement
- Parameters:
unused
- the suggested fetch size- Throws:
- java.sql.SQLException - this is never thrown
setMaxFieldSize
public void setMaxFieldSize(int max)
throws java.sql.SQLException
- Sets the maximum field size for certain data types. If data
of that type is retrieved from the database and it exceeds this
value, the excess data will be silently discarded.
- Specified by:
- setMaxFieldSize(int) in interface java.sql.Statement
- Parameters:
max
- the maximum field size- Throws:
- java.sql.SQLException - this is never thrown
setMaxRows
public void setMaxRows(int max)
throws java.sql.SQLException
- Sets the maximum number of rows to be returned by results generated
by this statement. It will silently discard excess rows.
- Specified by:
- setMaxRows(int) in interface java.sql.Statement
- Parameters:
max
- the maximum number of rows- Throws:
- java.sql.SQLException - this is never thrown