Package com.mysql.cj.jdbc
Class StatementImpl
java.lang.Object
com.mysql.cj.jdbc.StatementImpl
- All Implemented Interfaces:
JdbcStatement
,Query
,java.lang.AutoCloseable
,java.sql.Statement
,java.sql.Wrapper
- Direct Known Subclasses:
ClientPreparedStatement
public class StatementImpl extends java.lang.Object implements JdbcStatement
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.
-
Nested Class Summary
-
Field Summary
Fields Modifier and Type Field Description protected java.util.ArrayList<Row>
batchedGeneratedKeys
protected java.lang.String
charEncoding
The character encoding to use (if available)protected NativeMessageBuilder
commandBuilder
protected JdbcConnection
connection
The connection that created usprotected boolean
continueBatchOnError
protected boolean
doEscapeProcessing
Should we process escape codes?protected boolean
dontCheckOnDuplicateKeyUpdateInSQL
protected RuntimeProperty<java.lang.Boolean>
dontTrackOpenResources
protected RuntimeProperty<java.lang.Boolean>
dumpQueriesOnException
protected ExceptionInterceptor
exceptionInterceptor
protected ResultSetInternalMethods
generatedKeysResults
protected boolean
holdResultsOpenOverClose
Should this statement hold results open over .close() irregardless of connection's setting?protected boolean
isClosed
Has this statement been closed?protected long
lastInsertId
The auto_increment value for the last insertprotected boolean
lastQueryIsOnDupKeyUpdate
Whether or not the last query was of the form ON DUPLICATE KEY UPDATEprotected boolean
logSlowQueries
protected RuntimeProperty<java.lang.Integer>
maxAllowedPacket
protected int
maxFieldSize
The max field size for this statementint
maxRows
The maximum number of rows to return for this statement (-1 means _all_ rows)protected java.util.Set<ResultSetInternalMethods>
openResults
Set of currently-open ResultSetsprotected boolean
pedantic
Are we in pedantic mode?protected static java.lang.String
PING_MARKER
protected PingTarget
pingTarget
protected boolean
profileSQL
Should we profile?protected Query
query
protected ResultSetInternalMethods
results
The current resultsprotected int
resultSetConcurrency
The concurrency for this result set (updatable or not)protected ResultSetFactory
resultSetFactory
protected boolean
retrieveGeneratedKeys
protected RuntimeProperty<java.lang.Boolean>
rewriteBatchedStatements
protected NativeSession
session
protected long
updateCount
The update count for this statementstatic byte
USES_VARIABLES_FALSE
static byte
USES_VARIABLES_TRUE
static byte
USES_VARIABLES_UNKNOWN
protected boolean
useUsageAdvisor
Should we use the usage advisor?protected java.sql.SQLWarning
warningChain
The warnings chain. -
Constructor Summary
Constructors Constructor Description StatementImpl(JdbcConnection c, java.lang.String db)
Constructor for a Statement. -
Method Summary
Modifier and Type Method Description void
addBatch(java.lang.Object batch)
void
addBatch(java.lang.String sql)
void
cancel()
void
checkCancelTimeout()
protected JdbcConnection
checkClosed()
Checks if closed() has been called, and throws an exception if soprotected void
checkForDml(java.lang.String sql, char firstStatementChar)
Checks if the given SQL query with the given first non-ws char is a DML statement.protected void
checkNullOrEmptyQuery(java.lang.String sql)
Method checkNullOrEmptyQuery.void
clearBatch()
void
clearBatchedArgs()
void
clearWarnings()
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.protected void
closeAllOpenResults()
Close any open result sets that have been 'held open'void
closeOnCompletion()
void
closeQuery()
protected boolean
containsOnDuplicateKeyInString(java.lang.String sql)
protected boolean
createStreamingResultSet()
We only stream result sets when they are forward-only, read-only, and the fetch size has been set to Integer.MIN_VALUEvoid
disableStreamingResults()
Resets this statements fetch size and result set type to the values they had before enableStreamingResults() was called.protected void
doPingInstead()
void
enableStreamingResults()
Workaround for containers that 'check' for sane values of Statement.setFetchSize() so that applications can use the Java variant of libmysql's mysql_use_result() behavior.boolean
execute(java.lang.String sql)
boolean
execute(java.lang.String sql, int returnGeneratedKeys)
boolean
execute(java.lang.String sql, int[] generatedKeyIndices)
boolean
execute(java.lang.String sql, java.lang.String[] generatedKeyNames)
int[]
executeBatch()
protected long[]
executeBatchInternal()
long[]
executeLargeBatch()
long
executeLargeUpdate(java.lang.String sql)
long
executeLargeUpdate(java.lang.String sql, int autoGeneratedKeys)
long
executeLargeUpdate(java.lang.String sql, int[] columnIndexes)
long
executeLargeUpdate(java.lang.String sql, java.lang.String[] columnNames)
java.sql.ResultSet
executeQuery(java.lang.String sql)
void
executeSimpleNonQuery(JdbcConnection c, java.lang.String nonQuery)
int
executeUpdate(java.lang.String sql)
int
executeUpdate(java.lang.String sql, int autoGeneratedKeys)
int
executeUpdate(java.lang.String sql, int[] columnIndexes)
int
executeUpdate(java.lang.String sql, java.lang.String[] columnNames)
protected long
executeUpdateInternal(java.lang.String sql, boolean isBatch, boolean returnGeneratedKeys)
protected static int
findStartOfStatement(java.lang.String sql)
protected ResultSetInternalMethods
generatePingResultSet()
java.util.List<java.lang.Object>
getBatchedArgs()
Get the batched args as added by the addBatch method(s).protected void
getBatchedGeneratedKeys(int maxKeys)
protected void
getBatchedGeneratedKeys(java.sql.Statement batchedStatement)
java.lang.Object
getCancelTimeoutMutex()
java.sql.Connection
getConnection()
java.lang.String
getCurrentDatabase()
ExceptionInterceptor
getExceptionInterceptor()
long
getExecuteTime()
Returns the elapsed time for the server to execute the query.int
getFetchDirection()
int
getFetchSize()
java.sql.ResultSet
getGeneratedKeys()
protected ResultSetInternalMethods
getGeneratedKeysInternal()
protected ResultSetInternalMethods
getGeneratedKeysInternal(long numKeys)
int
getId()
Returns the query id used when profilinglong
getLargeMaxRows()
long
getLargeUpdateCount()
long
getLastInsertID()
getLastInsertID returns the value of the auto_incremented key after an executeQuery() or excute() call.java.io.InputStream
getLocalInfileInputStream()
Returns the InputStream instance that will be used to send data in response to a "LOAD DATA LOCAL INFILE" statement.long
getLongUpdateCount()
getLongUpdateCount returns the current result as an update count, if the result is a ResultSet or there are no more results, -1 is returned.int
getMaxFieldSize()
int
getMaxRows()
boolean
getMoreResults()
boolean
getMoreResults(int current)
int
getOpenResultSetCount()
Returns the number of open result sets for this statement.Query
getQuery()
int
getQueryTimeout()
int
getResultFetchSize()
java.sql.ResultSet
getResultSet()
int
getResultSetConcurrency()
<T extends Resultset, M extends Message>
ProtocolEntityFactory<T,M>getResultSetFactory()
int
getResultSetHoldability()
protected ResultSetInternalMethods
getResultSetInternal()
int
getResultSetType()
Resultset.Type
getResultType()
long
getServerStatementId()
Session
getSession()
java.util.concurrent.atomic.AtomicBoolean
getStatementExecuting()
int
getTimeoutInMillis()
int
getUpdateCount()
java.sql.SQLWarning
getWarnings()
protected java.sql.SQLException
handleExceptionForBatch(int endOfBatchIndex, int numValuesPerBatch, long[] updateCounts, java.sql.SQLException ex)
protected boolean
hasDeadlockOrTimeoutRolledBackTx(java.sql.SQLException ex)
protected void
implicitlyCloseAllOpenResults()
Close all result sets in this statement.protected void
initQuery()
boolean
isClearWarningsCalled()
boolean
isClosed()
boolean
isCloseOnCompletion()
boolean
isPoolable()
boolean
isWrapperFor(java.lang.Class<?> iface)
protected int
processMultiCountsAndKeys(StatementImpl batchedStatement, int updateCountCounter, long[] updateCounts)
protected void
realClose(boolean calledExplicitly, boolean closeOpenResults)
Closes this statement, and frees resources.void
removeOpenResultSet(ResultSetInternalMethods rs)
Callback for result set instances to remove them from the Set that tracks them per-statementvoid
resetCancelledState()
void
setCancelStatus(Query.CancelStatus cs)
void
setClearWarningsCalled(boolean clearWarningsCalled)
void
setCurrentDatabase(java.lang.String currentDb)
void
setCursorName(java.lang.String name)
void
setEscapeProcessing(boolean enable)
void
setExecuteTime(long executeTime)
void
setFetchDirection(int direction)
void
setFetchSize(int rows)
void
setHoldResultsOpenOverClose(boolean holdResultsOpenOverClose)
void
setLargeMaxRows(long max)
void
setLocalInfileInputStream(java.io.InputStream stream)
Sets an InputStream instance that will be used to send data to the MySQL server for a "LOAD DATA LOCAL INFILE" statement rather than a FileInputStream or URLInputStream that represents the path given as an argument to the statement.void
setMaxFieldSize(int max)
void
setMaxRows(int max)
void
setPingTarget(PingTarget pingTarget)
void
setPoolable(boolean poolable)
void
setQueryTimeout(int seconds)
void
setResultFetchSize(int fetchSize)
void
setResultType(Resultset.Type resultSetType)
void
setTimeoutInMillis(int timeoutInMillis)
protected void
setupStreamingTimeout(JdbcConnection con)
Adjust net_write_timeout to a higher value if we're streaming result sets.CancelQueryTask
startQueryTimer(Query stmtToCancel, int timeout)
void
statementBegins()
void
stopQueryTimer(CancelQueryTask timeoutTask, boolean rethrowCancelReason, boolean checkCancelTimeout)
<T> T
unwrap(java.lang.Class<T> iface)
-
Field Details
-
PING_MARKER
protected static final java.lang.String PING_MARKER- See Also:
- Constant Field Values
-
commandBuilder
-
USES_VARIABLES_FALSE
public static final byte USES_VARIABLES_FALSE- See Also:
- Constant Field Values
-
USES_VARIABLES_TRUE
public static final byte USES_VARIABLES_TRUE- See Also:
- Constant Field Values
-
USES_VARIABLES_UNKNOWN
public static final byte USES_VARIABLES_UNKNOWN- See Also:
- Constant Field Values
-
charEncoding
protected java.lang.String charEncodingThe character encoding to use (if available) -
connection
The connection that created us -
doEscapeProcessing
protected boolean doEscapeProcessingShould we process escape codes? -
isClosed
protected boolean isClosedHas this statement been closed? -
lastInsertId
protected long lastInsertIdThe auto_increment value for the last insert -
maxFieldSize
protected int maxFieldSizeThe max field size for this statement -
maxRows
public int maxRowsThe maximum number of rows to return for this statement (-1 means _all_ rows) -
openResults
Set of currently-open ResultSets -
pedantic
protected boolean pedanticAre we in pedantic mode? -
profileSQL
protected boolean profileSQLShould we profile? -
results
The current results -
generatedKeysResults
-
resultSetConcurrency
protected int resultSetConcurrencyThe concurrency for this result set (updatable or not) -
updateCount
protected long updateCountThe update count for this statement -
useUsageAdvisor
protected boolean useUsageAdvisorShould we use the usage advisor? -
warningChain
protected java.sql.SQLWarning warningChainThe warnings chain. -
holdResultsOpenOverClose
protected boolean holdResultsOpenOverCloseShould this statement hold results open over .close() irregardless of connection's setting? -
batchedGeneratedKeys
-
retrieveGeneratedKeys
protected boolean retrieveGeneratedKeys -
continueBatchOnError
protected boolean continueBatchOnError -
pingTarget
-
exceptionInterceptor
-
lastQueryIsOnDupKeyUpdate
protected boolean lastQueryIsOnDupKeyUpdateWhether or not the last query was of the form ON DUPLICATE KEY UPDATE -
dontTrackOpenResources
-
dumpQueriesOnException
-
logSlowQueries
protected boolean logSlowQueries -
rewriteBatchedStatements
-
maxAllowedPacket
-
dontCheckOnDuplicateKeyUpdateInSQL
protected boolean dontCheckOnDuplicateKeyUpdateInSQL -
resultSetFactory
-
query
-
session
-
-
Constructor Details
-
StatementImpl
Constructor for a Statement.- Parameters:
c
- the Connection instance that creates usdb
- the database name in use when we were created- Throws:
java.sql.SQLException
- if an error occurs.
-
-
Method Details
-
initQuery
protected void initQuery() -
addBatch
public void addBatch(java.lang.String sql) throws java.sql.SQLException- Specified by:
addBatch
in interfacejava.sql.Statement
- Throws:
java.sql.SQLException
-
addBatch
public void addBatch(java.lang.Object batch) -
getBatchedArgs
public java.util.List<java.lang.Object> getBatchedArgs()Description copied from interface:Query
Get the batched args as added by the addBatch method(s). The list is unmodifiable and might contain any combination of String, ClientPreparedQueryBindings, or ServerPreparedQueryBindings depending on how the parameters were batched.- Specified by:
getBatchedArgs
in interfaceQuery
- Returns:
- an unmodifiable List of batched args
-
cancel
public void cancel() throws java.sql.SQLException- Specified by:
cancel
in interfacejava.sql.Statement
- Throws:
java.sql.SQLException
-
checkClosed
Checks if closed() has been called, and throws an exception if so- Returns:
- connection
- Throws:
StatementIsClosedException
- if this statement has been closed
-
checkForDml
protected void checkForDml(java.lang.String sql, char firstStatementChar) throws java.sql.SQLExceptionChecks if the given SQL query with the given first non-ws char is a DML statement. Throws an exception if it is.- Parameters:
sql
- the SQL to checkfirstStatementChar
- the UC first non-ws char of the statement- Throws:
java.sql.SQLException
- if the statement contains DML
-
checkNullOrEmptyQuery
protected void checkNullOrEmptyQuery(java.lang.String sql) throws java.sql.SQLExceptionMethod checkNullOrEmptyQuery.- Parameters:
sql
- the SQL to check- Throws:
java.sql.SQLException
- if query is null or empty.
-
clearBatch
public void clearBatch() throws java.sql.SQLException- Specified by:
clearBatch
in interfacejava.sql.Statement
- Throws:
java.sql.SQLException
-
clearBatchedArgs
public void clearBatchedArgs()- Specified by:
clearBatchedArgs
in interfaceQuery
-
clearWarnings
public void clearWarnings() throws java.sql.SQLException- Specified by:
clearWarnings
in interfacejava.sql.Statement
- Throws:
java.sql.SQLException
-
close
public void close() throws java.sql.SQLExceptionIn 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 interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.sql.Statement
- Throws:
java.sql.SQLException
- if a database access error occurs
-
closeAllOpenResults
protected void closeAllOpenResults() throws java.sql.SQLExceptionClose any open result sets that have been 'held open'- Throws:
java.sql.SQLException
- if an error occurs
-
implicitlyCloseAllOpenResults
protected void implicitlyCloseAllOpenResults() throws java.sql.SQLExceptionClose all result sets in this statement. This includes multi-results- Throws:
java.sql.SQLException
- if a database access error occurs
-
removeOpenResultSet
Description copied from interface:JdbcStatement
Callback for result set instances to remove them from the Set that tracks them per-statement- Specified by:
removeOpenResultSet
in interfaceJdbcStatement
- Parameters:
rs
- result set
-
getOpenResultSetCount
public int getOpenResultSetCount()Description copied from interface:JdbcStatement
Returns the number of open result sets for this statement.- Specified by:
getOpenResultSetCount
in interfaceJdbcStatement
- Returns:
- the number of open result sets for this statement
-
createStreamingResultSet
protected boolean createStreamingResultSet()We only stream result sets when they are forward-only, read-only, and the fetch size has been set to Integer.MIN_VALUE- Returns:
- true if this result set should be streamed row at-a-time, rather than read all at once.
-
enableStreamingResults
public void enableStreamingResults() throws java.sql.SQLExceptionDescription copied from interface:JdbcStatement
Workaround for containers that 'check' for sane values of Statement.setFetchSize() so that applications can use the Java variant of libmysql's mysql_use_result() behavior.- Specified by:
enableStreamingResults
in interfaceJdbcStatement
- Throws:
java.sql.SQLException
- if an error occurs
-
disableStreamingResults
public void disableStreamingResults() throws java.sql.SQLExceptionDescription copied from interface:JdbcStatement
Resets this statements fetch size and result set type to the values they had before enableStreamingResults() was called.- Specified by:
disableStreamingResults
in interfaceJdbcStatement
- Throws:
java.sql.SQLException
- if an error occurs
-
setupStreamingTimeout
Adjust net_write_timeout to a higher value if we're streaming result sets. More often than not, someone runs into an issue where they blow net_write_timeout when using this feature, and if they're willing to hold a result set open for 30 seconds or more, one more round-trip isn't going to hurt. This is reset by RowDataDynamic.close().- Parameters:
con
- created this statement- Throws:
java.sql.SQLException
- if a database error occurs
-
startQueryTimer
- Specified by:
startQueryTimer
in interfaceQuery
-
stopQueryTimer
public void stopQueryTimer(CancelQueryTask timeoutTask, boolean rethrowCancelReason, boolean checkCancelTimeout)- Specified by:
stopQueryTimer
in interfaceQuery
-
execute
public boolean execute(java.lang.String sql) throws java.sql.SQLException- Specified by:
execute
in interfacejava.sql.Statement
- Throws:
java.sql.SQLException
-
statementBegins
public void statementBegins()- Specified by:
statementBegins
in interfaceQuery
-
resetCancelledState
public void resetCancelledState()- Specified by:
resetCancelledState
in interfaceQuery
-
execute
public boolean execute(java.lang.String sql, int returnGeneratedKeys) throws java.sql.SQLException- Specified by:
execute
in interfacejava.sql.Statement
- Throws:
java.sql.SQLException
-
execute
public boolean execute(java.lang.String sql, int[] generatedKeyIndices) throws java.sql.SQLException- Specified by:
execute
in interfacejava.sql.Statement
- Throws:
java.sql.SQLException
-
execute
public boolean execute(java.lang.String sql, java.lang.String[] generatedKeyNames) throws java.sql.SQLException- Specified by:
execute
in interfacejava.sql.Statement
- Throws:
java.sql.SQLException
-
executeBatch
public int[] executeBatch() throws java.sql.SQLException- Specified by:
executeBatch
in interfacejava.sql.Statement
- Throws:
java.sql.SQLException
-
executeBatchInternal
protected long[] executeBatchInternal() throws java.sql.SQLException- Throws:
java.sql.SQLException
-
hasDeadlockOrTimeoutRolledBackTx
protected final boolean hasDeadlockOrTimeoutRolledBackTx(java.sql.SQLException ex) -
processMultiCountsAndKeys
protected int processMultiCountsAndKeys(StatementImpl batchedStatement, int updateCountCounter, long[] updateCounts) throws java.sql.SQLException- Throws:
java.sql.SQLException
-
handleExceptionForBatch
protected java.sql.SQLException handleExceptionForBatch(int endOfBatchIndex, int numValuesPerBatch, long[] updateCounts, java.sql.SQLException ex) throws java.sql.BatchUpdateException, java.sql.SQLException- Throws:
java.sql.BatchUpdateException
java.sql.SQLException
-
executeQuery
public java.sql.ResultSet executeQuery(java.lang.String sql) throws java.sql.SQLException- Specified by:
executeQuery
in interfacejava.sql.Statement
- Throws:
java.sql.SQLException
-
doPingInstead
protected void doPingInstead() throws java.sql.SQLException- Throws:
java.sql.SQLException
-
generatePingResultSet
- Throws:
java.sql.SQLException
-
executeSimpleNonQuery
public void executeSimpleNonQuery(JdbcConnection c, java.lang.String nonQuery) throws java.sql.SQLException- Throws:
java.sql.SQLException
-
executeUpdate
public int executeUpdate(java.lang.String sql) throws java.sql.SQLException- Specified by:
executeUpdate
in interfacejava.sql.Statement
- Throws:
java.sql.SQLException
-
executeUpdateInternal
protected long executeUpdateInternal(java.lang.String sql, boolean isBatch, boolean returnGeneratedKeys) throws java.sql.SQLException- Throws:
java.sql.SQLException
-
executeUpdate
public int executeUpdate(java.lang.String sql, int autoGeneratedKeys) throws java.sql.SQLException- Specified by:
executeUpdate
in interfacejava.sql.Statement
- Throws:
java.sql.SQLException
-
executeUpdate
public int executeUpdate(java.lang.String sql, int[] columnIndexes) throws java.sql.SQLException- Specified by:
executeUpdate
in interfacejava.sql.Statement
- Throws:
java.sql.SQLException
-
executeUpdate
public int executeUpdate(java.lang.String sql, java.lang.String[] columnNames) throws java.sql.SQLException- Specified by:
executeUpdate
in interfacejava.sql.Statement
- Throws:
java.sql.SQLException
-
getConnection
public java.sql.Connection getConnection() throws java.sql.SQLException- Specified by:
getConnection
in interfacejava.sql.Statement
- Throws:
java.sql.SQLException
-
getFetchDirection
public int getFetchDirection() throws java.sql.SQLException- Specified by:
getFetchDirection
in interfacejava.sql.Statement
- Throws:
java.sql.SQLException
-
getFetchSize
public int getFetchSize() throws java.sql.SQLException- Specified by:
getFetchSize
in interfacejava.sql.Statement
- Throws:
java.sql.SQLException
-
getGeneratedKeys
public java.sql.ResultSet getGeneratedKeys() throws java.sql.SQLException- Specified by:
getGeneratedKeys
in interfacejava.sql.Statement
- Throws:
java.sql.SQLException
-
getGeneratedKeysInternal
- Throws:
java.sql.SQLException
-
getGeneratedKeysInternal
protected ResultSetInternalMethods getGeneratedKeysInternal(long numKeys) throws java.sql.SQLException- Throws:
java.sql.SQLException
-
getLastInsertID
public long getLastInsertID()getLastInsertID returns the value of the auto_incremented key after an executeQuery() or excute() call.This gets around the un-threadsafe behavior of "select LAST_INSERT_ID()" which is tied to the Connection that created this Statement, and therefore could have had many INSERTS performed before one gets a chance to call "select LAST_INSERT_ID()".
- Returns:
- the last update ID.
-
getLongUpdateCount
public long getLongUpdateCount()getLongUpdateCount 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.This method returns longs as MySQL server returns 64-bit values for update counts
- Returns:
- the current update count.
-
getMaxFieldSize
public int getMaxFieldSize() throws java.sql.SQLException- Specified by:
getMaxFieldSize
in interfacejava.sql.Statement
- Throws:
java.sql.SQLException
-
getMaxRows
public int getMaxRows() throws java.sql.SQLException- Specified by:
getMaxRows
in interfacejava.sql.Statement
- Throws:
java.sql.SQLException
-
getMoreResults
public boolean getMoreResults() throws java.sql.SQLException- Specified by:
getMoreResults
in interfacejava.sql.Statement
- Throws:
java.sql.SQLException
-
getMoreResults
public boolean getMoreResults(int current) throws java.sql.SQLException- Specified by:
getMoreResults
in interfacejava.sql.Statement
- Throws:
java.sql.SQLException
-
getQueryTimeout
public int getQueryTimeout() throws java.sql.SQLException- Specified by:
getQueryTimeout
in interfacejava.sql.Statement
- Throws:
java.sql.SQLException
-
getResultSet
public java.sql.ResultSet getResultSet() throws java.sql.SQLException- Specified by:
getResultSet
in interfacejava.sql.Statement
- Throws:
java.sql.SQLException
-
getResultSetConcurrency
public int getResultSetConcurrency() throws java.sql.SQLException- Specified by:
getResultSetConcurrency
in interfacejava.sql.Statement
- Throws:
java.sql.SQLException
-
getResultSetHoldability
public int getResultSetHoldability() throws java.sql.SQLException- Specified by:
getResultSetHoldability
in interfacejava.sql.Statement
- Throws:
java.sql.SQLException
-
getResultSetInternal
-
getResultSetType
public int getResultSetType() throws java.sql.SQLException- Specified by:
getResultSetType
in interfacejava.sql.Statement
- Throws:
java.sql.SQLException
-
getUpdateCount
public int getUpdateCount() throws java.sql.SQLException- Specified by:
getUpdateCount
in interfacejava.sql.Statement
- Throws:
java.sql.SQLException
-
getWarnings
public java.sql.SQLWarning getWarnings() throws java.sql.SQLException- Specified by:
getWarnings
in interfacejava.sql.Statement
- Throws:
java.sql.SQLException
-
realClose
protected void realClose(boolean calledExplicitly, boolean closeOpenResults) throws java.sql.SQLExceptionCloses this statement, and frees resources.- Parameters:
calledExplicitly
- was this called from close()?closeOpenResults
- should open result sets be closed?- Throws:
java.sql.SQLException
- if an error occurs
-
setCursorName
public void setCursorName(java.lang.String name) throws java.sql.SQLException- Specified by:
setCursorName
in interfacejava.sql.Statement
- Throws:
java.sql.SQLException
-
setEscapeProcessing
public void setEscapeProcessing(boolean enable) throws java.sql.SQLException- Specified by:
setEscapeProcessing
in interfacejava.sql.Statement
- Throws:
java.sql.SQLException
-
setFetchDirection
public void setFetchDirection(int direction) throws java.sql.SQLException- Specified by:
setFetchDirection
in interfacejava.sql.Statement
- Throws:
java.sql.SQLException
-
setFetchSize
public void setFetchSize(int rows) throws java.sql.SQLException- Specified by:
setFetchSize
in interfacejava.sql.Statement
- Throws:
java.sql.SQLException
-
setHoldResultsOpenOverClose
public void setHoldResultsOpenOverClose(boolean holdResultsOpenOverClose)- Specified by:
setHoldResultsOpenOverClose
in interfaceJdbcStatement
-
setMaxFieldSize
public void setMaxFieldSize(int max) throws java.sql.SQLException- Specified by:
setMaxFieldSize
in interfacejava.sql.Statement
- Throws:
java.sql.SQLException
-
setMaxRows
public void setMaxRows(int max) throws java.sql.SQLException- Specified by:
setMaxRows
in interfacejava.sql.Statement
- Throws:
java.sql.SQLException
-
setQueryTimeout
public void setQueryTimeout(int seconds) throws java.sql.SQLException- Specified by:
setQueryTimeout
in interfacejava.sql.Statement
- Throws:
java.sql.SQLException
-
getBatchedGeneratedKeys
protected void getBatchedGeneratedKeys(java.sql.Statement batchedStatement) throws java.sql.SQLException- Throws:
java.sql.SQLException
-
getBatchedGeneratedKeys
protected void getBatchedGeneratedKeys(int maxKeys) throws java.sql.SQLException- Throws:
java.sql.SQLException
-
isClosed
public boolean isClosed() throws java.sql.SQLException- Specified by:
isClosed
in interfacejava.sql.Statement
- Throws:
java.sql.SQLException
-
isPoolable
public boolean isPoolable() throws java.sql.SQLException- Specified by:
isPoolable
in interfacejava.sql.Statement
- Throws:
java.sql.SQLException
-
setPoolable
public void setPoolable(boolean poolable) throws java.sql.SQLException- Specified by:
setPoolable
in interfacejava.sql.Statement
- Throws:
java.sql.SQLException
-
isWrapperFor
public boolean isWrapperFor(java.lang.Class<?> iface) throws java.sql.SQLException- Specified by:
isWrapperFor
in interfacejava.sql.Wrapper
- Throws:
java.sql.SQLException
-
unwrap
public <T> T unwrap(java.lang.Class<T> iface) throws java.sql.SQLException- Specified by:
unwrap
in interfacejava.sql.Wrapper
- Throws:
java.sql.SQLException
-
findStartOfStatement
protected static int findStartOfStatement(java.lang.String sql) -
getLocalInfileInputStream
public java.io.InputStream getLocalInfileInputStream()Description copied from interface:JdbcStatement
Returns the InputStream instance that will be used to send data in response to a "LOAD DATA LOCAL INFILE" statement. This method returns NULL if no such stream has been set via setLocalInfileInputStream().- Specified by:
getLocalInfileInputStream
in interfaceJdbcStatement
- Returns:
- input stream
-
setLocalInfileInputStream
public void setLocalInfileInputStream(java.io.InputStream stream)Description copied from interface:JdbcStatement
Sets an InputStream instance that will be used to send data to the MySQL server for a "LOAD DATA LOCAL INFILE" statement rather than a FileInputStream or URLInputStream that represents the path given as an argument to the statement. This stream will be read to completion upon execution of a "LOAD DATA LOCAL INFILE" statement, and will automatically be closed by the driver, so it needs to be reset before each call to execute*() that would cause the MySQL server to request data to fulfill the request for "LOAD DATA LOCAL INFILE". If this value is set to NULL, the driver will revert to using a FileInputStream or URLInputStream as required.- Specified by:
setLocalInfileInputStream
in interfaceJdbcStatement
- Parameters:
stream
- input stream
-
setPingTarget
- Specified by:
setPingTarget
in interfaceJdbcStatement
-
getExceptionInterceptor
- Specified by:
getExceptionInterceptor
in interfaceJdbcStatement
-
containsOnDuplicateKeyInString
protected boolean containsOnDuplicateKeyInString(java.lang.String sql) -
closeOnCompletion
public void closeOnCompletion() throws java.sql.SQLException- Specified by:
closeOnCompletion
in interfacejava.sql.Statement
- Throws:
java.sql.SQLException
-
isCloseOnCompletion
public boolean isCloseOnCompletion() throws java.sql.SQLException- Specified by:
isCloseOnCompletion
in interfacejava.sql.Statement
- Throws:
java.sql.SQLException
-
executeLargeBatch
public long[] executeLargeBatch() throws java.sql.SQLException- Specified by:
executeLargeBatch
in interfacejava.sql.Statement
- Throws:
java.sql.SQLException
-
executeLargeUpdate
public long executeLargeUpdate(java.lang.String sql) throws java.sql.SQLException- Specified by:
executeLargeUpdate
in interfacejava.sql.Statement
- Throws:
java.sql.SQLException
-
executeLargeUpdate
public long executeLargeUpdate(java.lang.String sql, int autoGeneratedKeys) throws java.sql.SQLException- Specified by:
executeLargeUpdate
in interfacejava.sql.Statement
- Throws:
java.sql.SQLException
-
executeLargeUpdate
public long executeLargeUpdate(java.lang.String sql, int[] columnIndexes) throws java.sql.SQLException- Specified by:
executeLargeUpdate
in interfacejava.sql.Statement
- Throws:
java.sql.SQLException
-
executeLargeUpdate
public long executeLargeUpdate(java.lang.String sql, java.lang.String[] columnNames) throws java.sql.SQLException- Specified by:
executeLargeUpdate
in interfacejava.sql.Statement
- Throws:
java.sql.SQLException
-
getLargeMaxRows
public long getLargeMaxRows() throws java.sql.SQLException- Specified by:
getLargeMaxRows
in interfacejava.sql.Statement
- Throws:
java.sql.SQLException
-
getLargeUpdateCount
public long getLargeUpdateCount() throws java.sql.SQLException- Specified by:
getLargeUpdateCount
in interfacejava.sql.Statement
- Throws:
java.sql.SQLException
-
setLargeMaxRows
public void setLargeMaxRows(long max) throws java.sql.SQLException- Specified by:
setLargeMaxRows
in interfacejava.sql.Statement
- Throws:
java.sql.SQLException
-
getCurrentDatabase
public java.lang.String getCurrentDatabase()- Specified by:
getCurrentDatabase
in interfaceQuery
-
getServerStatementId
public long getServerStatementId() -
getResultSetFactory
- Specified by:
getResultSetFactory
in interfaceQuery
-
getId
public int getId()Description copied from interface:Query
Returns the query id used when profiling -
setCancelStatus
- Specified by:
setCancelStatus
in interfaceQuery
-
checkCancelTimeout
public void checkCancelTimeout()- Specified by:
checkCancelTimeout
in interfaceQuery
-
getSession
- Specified by:
getSession
in interfaceQuery
-
getCancelTimeoutMutex
public java.lang.Object getCancelTimeoutMutex()- Specified by:
getCancelTimeoutMutex
in interfaceQuery
-
closeQuery
public void closeQuery()- Specified by:
closeQuery
in interfaceQuery
-
getResultFetchSize
public int getResultFetchSize()- Specified by:
getResultFetchSize
in interfaceQuery
-
setResultFetchSize
public void setResultFetchSize(int fetchSize)- Specified by:
setResultFetchSize
in interfaceQuery
-
getResultType
- Specified by:
getResultType
in interfaceQuery
-
setResultType
- Specified by:
setResultType
in interfaceQuery
-
getTimeoutInMillis
public int getTimeoutInMillis()- Specified by:
getTimeoutInMillis
in interfaceQuery
-
setTimeoutInMillis
public void setTimeoutInMillis(int timeoutInMillis)- Specified by:
setTimeoutInMillis
in interfaceQuery
-
getExecuteTime
public long getExecuteTime()Description copied from interface:Query
Returns the elapsed time for the server to execute the query.- Specified by:
getExecuteTime
in interfaceQuery
- Returns:
- the time it took for the server to execute the query.
-
setExecuteTime
public void setExecuteTime(long executeTime)- Specified by:
setExecuteTime
in interfaceQuery
-
getStatementExecuting
public java.util.concurrent.atomic.AtomicBoolean getStatementExecuting()- Specified by:
getStatementExecuting
in interfaceQuery
-
setCurrentDatabase
public void setCurrentDatabase(java.lang.String currentDb)- Specified by:
setCurrentDatabase
in interfaceQuery
-
isClearWarningsCalled
public boolean isClearWarningsCalled()- Specified by:
isClearWarningsCalled
in interfaceQuery
-
setClearWarningsCalled
public void setClearWarningsCalled(boolean clearWarningsCalled)- Specified by:
setClearWarningsCalled
in interfaceQuery
-
getQuery
- Specified by:
getQuery
in interfaceJdbcStatement
-