public class MariaDbPreparedStatementServer extends BasePrepareStatement implements java.lang.Cloneable
Modifier and Type | Field and Description |
---|---|
(package private) java.util.Map<java.lang.Integer,ParameterHolder> |
currentParameterHolder |
private static Logger |
logger |
(package private) MariaDbResultSetMetaData |
metadata |
(package private) boolean |
mustExecuteOnMaster |
(package private) int |
parameterCount |
(package private) MariaDbParameterMetaData |
parameterMetaData |
(package private) java.util.List<ParameterHolder[]> |
queryParameters |
(package private) boolean |
returnTableAlias |
(package private) ServerPrepareResult |
serverPrepareResult |
(package private) java.lang.String |
sql |
hasLongData, useFractionalSeconds
batchQueries, canUseServerTimeout, closed, connection, executing, fetchSize, isTimedout, lock, maxRows, mustCloseOnCompletion, options, protocol, queryTimeout, results, resultSetScrollType, timerTaskFuture, warningsCleared
Constructor and Description |
---|
MariaDbPreparedStatementServer(MariaDbConnection connection,
java.lang.String sql,
int resultSetScrollType,
boolean forcePrepare)
Constructor for creating Server prepared statement.
|
Modifier and Type | Method and Description |
---|---|
void |
addBatch() |
void |
addBatch(java.lang.String sql)
Add batch.
|
void |
clearBatch()
Empties this
Statement object's current list of SQL send. |
void |
clearParameters() |
MariaDbPreparedStatementServer |
clone(MariaDbConnection connection)
Clone statement.
|
void |
close()
Releases this
Statement object's database and JDBC resources immediately instead of waiting for this
to happen when it is automatically closed. |
boolean |
execute() |
int[] |
executeBatch()
Submits a batch of send to the database for execution and if all send execute successfully, returns an
array of update counts.
|
private void |
executeBatchInternal(int queryParameterSize) |
protected boolean |
executeInternal(int fetchSize) |
long[] |
executeLargeBatch()
Execute batch, like executeBatch(), with returning results with long[].
|
java.sql.ResultSet |
executeQuery() |
private void |
executeQueryPrologue(ServerPrepareResult serverPrepareResult) |
int |
executeUpdate() |
java.sql.ResultSetMetaData |
getMetaData() |
protected int |
getParameterCount() |
java.sql.ParameterMetaData |
getParameterMetaData()
Retrieves the number, types and properties of this
PreparedStatement object's parameters. |
long |
getServerThreadId()
Permit to retrieve current connection thread id, or -1 if unknown.
|
private void |
prepare(java.lang.String sql) |
private void |
setMetaFromResult() |
protected void |
setParameter(int parameterIndex,
ParameterHolder holder) |
java.lang.String |
toString()
Return sql String value.
|
protected void |
validParameters() |
executeLargeUpdate, setArray, setAsciiStream, setAsciiStream, setAsciiStream, setBigDecimal, setBinaryStream, setBinaryStream, setBinaryStream, setBlob, setBlob, setBlob, setBoolean, setByte, setBytes, setCharacterStream, setCharacterStream, setCharacterStream, setClob, setClob, setClob, setDate, setDate, setDouble, setFloat, setInt, setInternalObject, setLong, setNCharacterStream, setNCharacterStream, setNClob, setNClob, setNClob, setNString, setNull, setNull, setNull, setObject, setObject, setObject, setObject, setObject, setRef, setRowId, setShort, setSQLXML, setString, setTime, setTime, setTimestamp, setTimestamp, setUnicodeStream, setURL
cancel, checkClose, checkCloseOnCompletion, clearWarnings, closeOnCompletion, execute, execute, execute, execute, executeBatchEpilogue, executeBatchExceptionEpilogue, executeEpilogue, executeExceptionEpilogue, executeInternal, executeLargeUpdate, executeLargeUpdate, executeLargeUpdate, executeLargeUpdate, executeQuery, executeQueryPrologue, executeUpdate, executeUpdate, executeUpdate, executeUpdate, getConnection, getFetchDirection, getFetchSize, getGeneratedKeys, getLargeMaxRows, getLargeUpdateCount, getMaxFieldSize, getMaxRows, getMoreResults, getMoreResults, getProtocol, getQueryTimeout, getResultSet, getResultSetConcurrency, getResultSetHoldability, getResultSetType, getUpdateCount, getWarnings, handleFailoverAndTimeout, internalBatchExecution, isClosed, isCloseOnCompletion, isPoolable, isWrapperFor, setCursorName, setEscapeProcessing, setFetchDirection, setFetchSize, setLargeMaxRows, setLocalInfileInputStream, setMaxFieldSize, setMaxRows, setPoolable, setQueryTimeout, setTimerTask, skipMoreResults, stopTimeoutTask, testExecute, unloadDriver, unwrap
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
cancel, clearWarnings, closeOnCompletion, execute, execute, execute, execute, executeLargeUpdate, executeLargeUpdate, executeLargeUpdate, executeLargeUpdate, executeQuery, executeUpdate, executeUpdate, executeUpdate, executeUpdate, getConnection, getFetchDirection, getFetchSize, getGeneratedKeys, getLargeMaxRows, getLargeUpdateCount, getMaxFieldSize, getMaxRows, getMoreResults, getMoreResults, getQueryTimeout, getResultSet, getResultSetConcurrency, getResultSetHoldability, getResultSetType, getUpdateCount, getWarnings, isClosed, isCloseOnCompletion, isPoolable, setCursorName, setEscapeProcessing, setFetchDirection, setFetchSize, setLargeMaxRows, setMaxFieldSize, setMaxRows, setPoolable, setQueryTimeout
private static Logger logger
java.lang.String sql
ServerPrepareResult serverPrepareResult
boolean returnTableAlias
int parameterCount
MariaDbResultSetMetaData metadata
MariaDbParameterMetaData parameterMetaData
java.util.Map<java.lang.Integer,ParameterHolder> currentParameterHolder
java.util.List<ParameterHolder[]> queryParameters
boolean mustExecuteOnMaster
public MariaDbPreparedStatementServer(MariaDbConnection connection, java.lang.String sql, int resultSetScrollType, boolean forcePrepare) throws java.sql.SQLException
connection
- current connectionsql
- Sql String to prepareresultSetScrollType
- one of the following ResultSet
constants: ResultSet.TYPE_FORWARD_ONLY
,
ResultSet.TYPE_SCROLL_INSENSITIVE
, or ResultSet.TYPE_SCROLL_SENSITIVE
forcePrepare
- force immediate preparejava.sql.SQLException
- exceptionpublic MariaDbPreparedStatementServer clone(MariaDbConnection connection) throws java.lang.CloneNotSupportedException
clone
in class BasePrepareStatement
connection
- connectionjava.lang.CloneNotSupportedException
- if any error occur.private void prepare(java.lang.String sql) throws java.sql.SQLException
java.sql.SQLException
private void setMetaFromResult()
protected void setParameter(int parameterIndex, ParameterHolder holder) throws java.sql.SQLException
setParameter
in class BasePrepareStatement
java.sql.SQLException
public void addBatch() throws java.sql.SQLException
addBatch
in interface java.sql.PreparedStatement
java.sql.SQLException
public void addBatch(java.lang.String sql) throws java.sql.SQLException
addBatch
in interface java.sql.Statement
addBatch
in class MariaDbStatement
sql
- typically this is a SQL INSERT
or UPDATE
statementjava.sql.SQLException
- every time since that method is forbidden on prepareStatementMariaDbStatement.executeBatch()
,
DatabaseMetaData.supportsBatchUpdates()
public void clearBatch()
MariaDbStatement
Statement
object's current list of SQL send.clearBatch
in interface java.sql.Statement
clearBatch
in class MariaDbStatement
MariaDbStatement.addBatch(java.lang.String)
,
DatabaseMetaData.supportsBatchUpdates()
public java.sql.ParameterMetaData getParameterMetaData() throws java.sql.SQLException
BasePrepareStatement
PreparedStatement
object's parameters.getParameterMetaData
in interface java.sql.PreparedStatement
getParameterMetaData
in class BasePrepareStatement
ParameterMetaData
object that contains information about the number, types and properties
for each parameter marker of this PreparedStatement
objectjava.sql.SQLException
- if a database access error occurs or this method is called on a closed
PreparedStatement
ParameterMetaData
public java.sql.ResultSetMetaData getMetaData() throws java.sql.SQLException
getMetaData
in interface java.sql.PreparedStatement
java.sql.SQLException
public int[] executeBatch() throws java.sql.SQLException
Submits a batch of send to the database for execution and if all send execute successfully, returns an
array of update counts. The int
elements of the array that is returned are ordered to correspond to
the send in the batch, which are ordered according to the order in which they were added to the batch. The
elements in the array returned by the method executeBatch
may be one of the following:
SUCCESS_NO_INFO
-- indicates that the command was processed successfully but that the number of rows
affected is unknown.
If one of the send in a batch update fails to execute properly, this method throws a
BatchUpdateException
, and a JDBC driver may or may not continue to process the remaining send in
the batch. However, the driver's behavior must be consistent with a particular DBMS, either always continuing to
process send or never continuing to process send. If the driver continues processing after a failure,
the array returned by the method BatchUpdateException.getUpdateCounts
will contain as many elements
as there are send in the batch, and at least one of the elements will be the following:
EXECUTE_FAILED
-- indicates that the command failed to execute successfully and
occurs only if a driver continues to process send after a command fails The possible implementations and return values have been modified in the Java 2 SDK, Standard Edition, version
1.3 to accommodate the option of continuing to proccess send in a batch update after a
BatchUpdateException
object has been thrown.
executeBatch
in interface java.sql.Statement
executeBatch
in class MariaDbStatement
java.sql.SQLException
- if a database access error occurs, this method is called on a closed
Statement
or the driver does not support batch statements. Throws
BatchUpdateException
(a subclass of SQLException
) if
one of the send sent to the database fails to execute properly or attempts to
return a result set.addBatch()
,
DatabaseMetaData.supportsBatchUpdates()
public long[] executeLargeBatch() throws java.sql.SQLException
executeLargeBatch
in interface java.sql.Statement
executeLargeBatch
in class MariaDbStatement
java.sql.SQLException
- if a database error occur.private void executeBatchInternal(int queryParameterSize) throws java.sql.SQLException
java.sql.SQLException
private void executeQueryPrologue(ServerPrepareResult serverPrepareResult) throws java.sql.SQLException
java.sql.SQLException
public java.sql.ResultSet executeQuery() throws java.sql.SQLException
executeQuery
in interface java.sql.PreparedStatement
java.sql.SQLException
public int executeUpdate() throws java.sql.SQLException
executeUpdate
in interface java.sql.PreparedStatement
java.sql.SQLException
public void clearParameters() throws java.sql.SQLException
clearParameters
in interface java.sql.PreparedStatement
java.sql.SQLException
public boolean execute() throws java.sql.SQLException
execute
in interface java.sql.PreparedStatement
java.sql.SQLException
protected void validParameters() throws java.sql.SQLException
java.sql.SQLException
protected boolean executeInternal(int fetchSize) throws java.sql.SQLException
executeInternal
in class BasePrepareStatement
java.sql.SQLException
public void close() throws java.sql.SQLException
Releases this Statement
object's database and JDBC resources immediately instead of waiting for this
to happen when it is automatically closed. It is generally good practice to release resources as soon as you are
finished with them to avoid tying up database resources.
Calling the method close
on a Statement
object that is already closed has no effect.
Note:When a Statement
object is closed, its current ResultSet
object, if one
exists, is also closed.
close
in interface java.lang.AutoCloseable
close
in interface java.sql.Statement
close
in class MariaDbStatement
java.sql.SQLException
- if a database access error occursprotected int getParameterCount()
public java.lang.String toString()
toString
in class java.lang.Object
public long getServerThreadId()
getServerThreadId
in class MariaDbStatement