Package org.mariadb.jdbc
Class ClientSidePreparedStatement
java.lang.Object
org.mariadb.jdbc.MariaDbStatement
org.mariadb.jdbc.BasePrepareStatement
org.mariadb.jdbc.ClientSidePreparedStatement
- All Implemented Interfaces:
AutoCloseable,Cloneable,PreparedStatement,Statement,Wrapper
- Direct Known Subclasses:
CallableFunctionStatement
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final Loggerprivate final List<ParameterHolder[]> private ParameterMetaDataprivate ParameterHolder[]private ClientPrepareResultprivate ResultSetMetaDataprivate StringFields inherited from class org.mariadb.jdbc.BasePrepareStatement
autoGeneratedKeys, hasLongData, SPEC_ISO_ZONED_DATE_TIMEFields inherited from class org.mariadb.jdbc.MariaDbStatement
canUseServerTimeout, closed, connection, executing, fetchSize, lock, maxRows, options, protocol, queryTimeout, results, resultSetConcurrency, resultSetScrollTypeFields inherited from interface java.sql.Statement
CLOSE_ALL_RESULTS, CLOSE_CURRENT_RESULT, EXECUTE_FAILED, KEEP_CURRENT_RESULT, NO_GENERATED_KEYS, RETURN_GENERATED_KEYS, SUCCESS_NO_INFO -
Constructor Summary
ConstructorsConstructorDescriptionClientSidePreparedStatement(MariaDbConnection connection, String sql, int resultSetScrollType, int resultSetConcurrency, int autoGeneratedKeys) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddBatch()Adds a set of parameters to thisPreparedStatementobject's batch of send.voidAdd batch.voidClear batch.voidClears the current parameter values immediately.clone(MariaDbConnection connection) Clone statement.voidclose()Releases thisStatementobject's database and JDBC resources immediately instead of waiting for this to happen when it is automatically closed.booleanexecute()Executes the SQL statement in thisPreparedStatementobject, which may be any kind of SQL statement.int[]{inheritdoc}.protected booleanexecuteInternal(int fetchSize) private voidexecuteInternalBatch(int size) Choose better way to execute queries according to query and options.long[]Execute batch, like executeBatch(), with returning results with long[].Executes the SQL query in thisPreparedStatementobject and returns theResultSetobject generated by the query.intExecutes the SQL statement in thisPreparedStatementobject, which must be an SQL Data Manipulation Language (DML) statement, such asINSERT,UPDATEorDELETE; or an SQL statement that returns nothing, such as a DDL statement.Retrieves aResultSetMetaDataobject that contains information about the columns of theResultSetobject that will be returned when thisPreparedStatementobject is executed.protected intRetrieves the number, types and properties of thisPreparedStatementobject's parameters.protected ClientPrepareResultint[]Non JDBC : Permit to retrieve server update counts when using option rewriteBatchedStatements.private voidvoidsetParameter(int parameterIndex, ParameterHolder holder) Set parameter.toString(){inherit}.Methods inherited from class org.mariadb.jdbc.BasePrepareStatement
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, setURLMethods inherited from class org.mariadb.jdbc.MariaDbStatement
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, unwrapMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.sql.Statement
cancel, clearWarnings, closeOnCompletion, enquoteIdentifier, enquoteLiteral, enquoteNCharLiteral, 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, isSimpleIdentifier, setCursorName, setEscapeProcessing, setFetchDirection, setFetchSize, setLargeMaxRows, setMaxFieldSize, setMaxRows, setPoolable, setQueryTimeoutMethods inherited from interface java.sql.Wrapper
isWrapperFor, unwrap
-
Field Details
-
logger
-
parameterList
-
prepareResult
-
sqlQuery
-
parameters
-
resultSetMetaData
-
parameterMetaData
-
-
Constructor Details
-
ClientSidePreparedStatement
public ClientSidePreparedStatement(MariaDbConnection connection, String sql, int resultSetScrollType, int resultSetConcurrency, int autoGeneratedKeys) throws SQLException Constructor.- Parameters:
connection- connectionsql- sql queryresultSetScrollType- one of the followingResultSetconstants:ResultSet.TYPE_FORWARD_ONLY,ResultSet.TYPE_SCROLL_INSENSITIVE, orResultSet.TYPE_SCROLL_SENSITIVEresultSetConcurrency- a concurrency type; one ofResultSet.CONCUR_READ_ONLYorResultSet.CONCUR_UPDATABLEautoGeneratedKeys- a flag indicating whether auto-generated keys should be returned; one ofStatement.RETURN_GENERATED_KEYSorStatement.NO_GENERATED_KEYS- Throws:
SQLException- exception
-
-
Method Details
-
clone
public ClientSidePreparedStatement clone(MariaDbConnection connection) throws CloneNotSupportedException Clone statement.- Overrides:
clonein classBasePrepareStatement- Parameters:
connection- connection- Returns:
- Clone statement.
- Throws:
CloneNotSupportedException- if any error occur.
-
execute
Executes the SQL statement in thisPreparedStatementobject, which may be any kind of SQL statement. Some prepared statements return multiple results; theexecutemethod handles these complex statements as well as the simpler form of statements handled by the methodsexecuteQueryandexecuteUpdate.
Theexecutemethod returns abooleanto indicate the form of the first result. You must call either the methodgetResultSetorgetUpdateCountto retrieve the result; you must callgetInternalMoreResultsto move to any subsequent result(s).- Returns:
trueif the first result is aResultSetobject;falseif the first result is an update count or there is no result- Throws:
SQLException- if a database access error occurs; this method is called on a closedPreparedStatementor an argument is supplied to this method- See Also:
-
executeQuery
Executes the SQL query in thisPreparedStatementobject and returns theResultSetobject generated by the query.- Returns:
- a
ResultSetobject that contains the data produced by the query; nevernull - Throws:
SQLException- if a database access error occurs; this method is called on a closedPreparedStatementor the SQL statement does not return aResultSetobject
-
executeUpdate
Executes the SQL statement in thisPreparedStatementobject, which must be an SQL Data Manipulation Language (DML) statement, such asINSERT,UPDATEorDELETE; or an SQL statement that returns nothing, such as a DDL statement.- Returns:
- either (1) the row count for SQL Data Manipulation Language (DML) statements or (2) 0 for SQL statements that return nothing
- Throws:
SQLException- if a database access error occurs; this method is called on a closedPreparedStatementor the SQL statement returns aResultSetobject
-
executeInternal
- Specified by:
executeInternalin classBasePrepareStatement- Throws:
SQLException
-
addBatch
Adds a set of parameters to thisPreparedStatementobject's batch of send.
- Throws:
SQLException- if a database access error occurs or this method is called on a closedPreparedStatement- Since:
- 1.2
- See Also:
-
addBatch
Add batch.- Specified by:
addBatchin interfaceStatement- Overrides:
addBatchin classMariaDbStatement- Parameters:
sql- typically this is a SQLINSERTorUPDATEstatement- Throws:
SQLException- every time since that method is forbidden on prepareStatement- See Also:
-
clearBatch
public void clearBatch()Clear batch.- Specified by:
clearBatchin interfaceStatement- Overrides:
clearBatchin classMariaDbStatement- See Also:
-
executeBatch
{inheritdoc}.- Specified by:
executeBatchin interfaceStatement- Overrides:
executeBatchin classMariaDbStatement- Returns:
- an array of update counts containing one element for each command in the batch. The elements of the array are ordered according to the order in which send were added to the batch.
- Throws:
SQLException- if a database access error occurs, this method is called on a closedStatementor the driver does not support batch statements. ThrowsBatchUpdateException(a subclass ofSQLException) if one of the send sent to the database fails to execute properly or attempts to return a result set.- See Also:
-
getServerUpdateCounts
public int[] getServerUpdateCounts()Non JDBC : Permit to retrieve server update counts when using option rewriteBatchedStatements.- Returns:
- an array of update counts containing one element for each command in the batch. The elements of the array are ordered according to the order in which commands were added to the batch.
-
executeLargeBatch
Execute batch, like executeBatch(), with returning results with long[]. For when row count may exceed Integer.MAX_VALUE.- Specified by:
executeLargeBatchin interfaceStatement- Overrides:
executeLargeBatchin classMariaDbStatement- Returns:
- an array of update counts (one element for each command in the batch)
- Throws:
SQLException- if a database error occur.
-
executeInternalBatch
Choose better way to execute queries according to query and options.- Parameters:
size- parameters number- Throws:
SQLException- if any error occur
-
getMetaData
Retrieves aResultSetMetaDataobject that contains information about the columns of theResultSetobject that will be returned when thisPreparedStatementobject is executed.
Because aPreparedStatementobject is precompiled, it is possible to know about theResultSetobject that it will return without having to execute it. Consequently, it is possible to invoke the methodgetMetaDataon aPreparedStatementobject rather than waiting to execute it and then invoking theResultSet.getMetaDatamethod on theResultSetobject that is returned.- Returns:
- the description of a
ResultSetobject's columns ornullif the driver cannot return aResultSetMetaDataobject - Throws:
SQLException- if a database access error occurs or this method is called on a closedPreparedStatement
-
setParameter
Set parameter.- Specified by:
setParameterin classBasePrepareStatement- Parameters:
parameterIndex- indexholder- parameter holder- Throws:
SQLException- if index position doesn't correspond to query parameters
-
getParameterMetaData
Retrieves the number, types and properties of thisPreparedStatementobject's parameters.- Specified by:
getParameterMetaDatain interfacePreparedStatement- Specified by:
getParameterMetaDatain classBasePrepareStatement- Returns:
- a
ParameterMetaDataobject that contains information about the number, types and properties for each parameter marker of thisPreparedStatementobject - Throws:
SQLException- if a database access error occurs or this method is called on a closedPreparedStatement- Since:
- 1.4
- See Also:
-
loadParametersData
- Throws:
SQLSyntaxErrorException
-
clearParameters
public void clearParameters()Clears the current parameter values immediately.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. -
close
Description copied from class:MariaDbStatementReleases thisStatementobject'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 methodcloseon aStatementobject that is already closed has no effect. Note:When aStatementobject is closed, its currentResultSetobject, if one exists, is also closed.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceStatement- Overrides:
closein classMariaDbStatement- Throws:
SQLException- if a database access error occurs
-
getParameterCount
protected int getParameterCount() -
toString
{inherit}. -
getPrepareResult
-