public class MariaDbPreparedStatementClient extends BasePrepareStatement
Modifier and Type | Field and Description |
---|---|
private static Logger |
logger |
private java.util.List<ParameterHolder[]> |
parameterList |
private java.sql.ParameterMetaData |
parameterMetaData |
private ParameterHolder[] |
parameters |
private ClientPrepareResult |
prepareResult |
private java.sql.ResultSetMetaData |
resultSetMetaData |
private java.lang.String |
sqlQuery |
autoGeneratedKeys, hasLongData, SPEC_ISO_ZONED_DATE_TIME
canUseServerTimeout, closed, connection, executing, fetchSize, lock, maxRows, options, protocol, queryTimeout, results, resultSetConcurrency, resultSetScrollType
Constructor and Description |
---|
MariaDbPreparedStatementClient(MariaDbConnection connection,
java.lang.String sql,
int resultSetScrollType,
int resultSetConcurrency,
int autoGeneratedKeys)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
addBatch()
Adds a set of parameters to this
PreparedStatement object's batch of send. |
void |
addBatch(java.lang.String sql)
Add batch.
|
void |
clearBatch()
Clear batch.
|
void |
clearParameters()
Clears the current parameter values immediately.
|
MariaDbPreparedStatementClient |
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()
Executes the SQL statement in this
PreparedStatement object,
which may be any kind of SQL statement. |
int[] |
executeBatch()
{inheritdoc}.
|
protected boolean |
executeInternal(int fetchSize) |
private void |
executeInternalBatch(int size)
Choose better way to execute queries according to query and options.
|
long[] |
executeLargeBatch()
Execute batch, like executeBatch(), with returning results with long[].
|
java.sql.ResultSet |
executeQuery()
Executes the SQL query in this
PreparedStatement object
and returns the ResultSet object generated by the query. |
int |
executeUpdate()
Executes the SQL statement in this
PreparedStatement object, which must be an SQL Data Manipulation
Language (DML) statement, such as INSERT , UPDATE or DELETE ; or an SQL
statement that returns nothing, such as a DDL statement. |
java.sql.ResultSetMetaData |
getMetaData()
Retrieves a
ResultSetMetaData object that contains information about the columns of the
ResultSet object that will be returned when this PreparedStatement object is executed. |
protected int |
getParameterCount() |
java.sql.ParameterMetaData |
getParameterMetaData()
Retrieves the number, types and properties of this
PreparedStatement object's parameters. |
protected ClientPrepareResult |
getPrepareResult() |
int[] |
getServerUpdateCounts()
non JDBC : Permit to retrieve server update counts when using option rewriteBatchedStatements.
|
private void |
loadParametersData() |
void |
setParameter(int parameterIndex,
ParameterHolder holder)
Set parameter.
|
java.lang.String |
toString()
{inherit}.
|
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, 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, executeLargeUpdate, executeLargeUpdate, executeLargeUpdate, executeLargeUpdate, executeQuery, executeQueryPrologue, executeUpdate, executeUpdate, executeUpdate, executeUpdate, getConnection, getFetchDirection, getFetchSize, getGeneratedKeys, getLargeMaxRows, getLargeUpdateCount, getMaxFieldSize, getMaxRows, getMoreResults, getMoreResults, getQueryTimeout, getResultSet, getResultSetConcurrency, getResultSetHoldability, getResultSetType, getServerThreadId, getUpdateCount, getWarnings, isClosed, isCloseOnCompletion, isPoolable, isWrapperFor, setCursorName, setEscapeProcessing, setFetchDirection, setFetchSize, setLargeMaxRows, setLocalInfileInputStream, setMaxFieldSize, setMaxRows, setPoolable, setQueryTimeout, setTimerTask, skipMoreResults, testExecute, 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 final Logger logger
private final java.util.List<ParameterHolder[]> parameterList
private ClientPrepareResult prepareResult
private java.lang.String sqlQuery
private ParameterHolder[] parameters
private java.sql.ResultSetMetaData resultSetMetaData
private java.sql.ParameterMetaData parameterMetaData
public MariaDbPreparedStatementClient(MariaDbConnection connection, java.lang.String sql, int resultSetScrollType, int resultSetConcurrency, int autoGeneratedKeys) throws java.sql.SQLException
connection
- connectionsql
- sql queryresultSetScrollType
- one of the following ResultSet
constants: ResultSet.TYPE_FORWARD_ONLY
,
ResultSet.TYPE_SCROLL_INSENSITIVE
, or ResultSet.TYPE_SCROLL_SENSITIVE
resultSetConcurrency
- a concurrency type; one of ResultSet.CONCUR_READ_ONLY
or
ResultSet.CONCUR_UPDATABLE
autoGeneratedKeys
- a flag indicating whether auto-generated keys should be returned; one of
Statement.RETURN_GENERATED_KEYS
or Statement.NO_GENERATED_KEYS
java.sql.SQLException
- exceptionpublic MariaDbPreparedStatementClient clone(MariaDbConnection connection) throws java.lang.CloneNotSupportedException
clone
in class BasePrepareStatement
connection
- connectionjava.lang.CloneNotSupportedException
- if any error occur.public boolean execute() throws java.sql.SQLException
PreparedStatement
object,
which may be any kind of SQL statement.
Some prepared statements return multiple results; the execute
method handles these complex statements as well as the simpler
form of statements handled by the methods executeQuery
and executeUpdate
.
execute
method returns a boolean
to
indicate the form of the first result. You must call either the method
getResultSet
or getUpdateCount
to retrieve the result; you must call getInternalMoreResults
to
move to any subsequent result(s).true
if the first result is a ResultSet
object; false
if the first result is an update
count or there is no resultjava.sql.SQLException
- if a database access error occurs;
this method is called on a closed PreparedStatement
or an argument is supplied to this methodStatement.execute(java.lang.String)
,
Statement.getResultSet()
,
Statement.getUpdateCount()
,
Statement.getMoreResults()
public java.sql.ResultSet executeQuery() throws java.sql.SQLException
PreparedStatement
object
and returns the ResultSet
object generated by the query.ResultSet
object that contains the data produced by the
query; never null
java.sql.SQLException
- if a database access error occurs;
this method is called on a closed PreparedStatement
or the SQL
statement does not return a ResultSet
objectpublic int executeUpdate() throws java.sql.SQLException
PreparedStatement
object, which must be an SQL Data Manipulation
Language (DML) statement, such as INSERT
, UPDATE
or DELETE
; or an SQL
statement that returns nothing, such as a DDL statement.java.sql.SQLException
- if a database access error occurs; this method is called on a closed
PreparedStatement
or the SQL statement returns a
ResultSet
objectprotected boolean executeInternal(int fetchSize) throws java.sql.SQLException
executeInternal
in class BasePrepareStatement
java.sql.SQLException
public void addBatch() throws java.sql.SQLException
PreparedStatement
object's batch of send.
java.sql.SQLException
- if a database access error occurs or this method is called on a closed
PreparedStatement
Statement.addBatch(java.lang.String)
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()
clearBatch
in interface java.sql.Statement
clearBatch
in class MariaDbStatement
MariaDbStatement.addBatch(java.lang.String)
,
DatabaseMetaData.supportsBatchUpdates()
public int[] executeBatch() throws java.sql.SQLException
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.MariaDbStatement.addBatch(java.lang.String)
,
DatabaseMetaData.supportsBatchUpdates()
public int[] getServerUpdateCounts()
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 executeInternalBatch(int size) throws java.sql.SQLException
size
- parameters numberjava.sql.SQLException
- if any error occurpublic java.sql.ResultSetMetaData getMetaData() throws java.sql.SQLException
ResultSetMetaData
object that contains information about the columns of the
ResultSet
object that will be returned when this PreparedStatement
object is executed.
PreparedStatement
object is precompiled, it is possible to know about the
ResultSet
object that it will return without having to execute it. Consequently, it is possible to
invoke the method getMetaData
on a PreparedStatement
object rather than waiting to
execute it and then invoking the ResultSet.getMetaData
method on the ResultSet
object
that is returned.ResultSet
object's columns or null
if the driver cannot
return a ResultSetMetaData
objectjava.sql.SQLException
- if a database access error occurs or this method is called on a closed
PreparedStatement
java.sql.SQLFeatureNotSupportedException
- if the JDBC driver does not support this methodpublic void setParameter(int parameterIndex, ParameterHolder holder) throws java.sql.SQLException
setParameter
in class BasePrepareStatement
parameterIndex
- indexholder
- parameter holderjava.sql.SQLException
- if index position doesn't correspond to query parameterspublic java.sql.ParameterMetaData getParameterMetaData() throws java.sql.SQLException
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
private void loadParametersData() throws java.sql.SQLSyntaxErrorException
java.sql.SQLSyntaxErrorException
public void clearParameters()
In general, parameter values remain in force for repeated use
of a statement. Setting a parameter value automatically clears its previous value. However, in some cases it is
useful to immediately release the resources used by the current parameter values; this can be done by calling the
method clearParameters
.
public void close() throws java.sql.SQLException
MariaDbStatement
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
protected ClientPrepareResult getPrepareResult()