- All Implemented Interfaces:
AutoCloseable
,PreparedStatement
,Statement
,Wrapper
,FirebirdPreparedStatement
,FirebirdStatement
- Direct Known Subclasses:
FBCallableStatement
PreparedStatement
.
This class is internal API of Jaybird. Future versions may radically change, move, or make inaccessible this type.
For the public API, refer to the PreparedStatement
and FirebirdPreparedStatement
interfaces.
- Author:
- David Jencks, Roman Rokytskyy, Mark Rotteveel
-
Nested Class Summary
Nested classes/interfaces inherited from class org.firebirdsql.jdbc.FBStatement
FBStatement.StatementResult
-
Field Summary
FieldsFields inherited from class org.firebirdsql.jdbc.FBStatement
currentStatementResult, fbStatement, gdsHelper, isSingletonResult, specialResult, statementListener
Fields inherited from class org.firebirdsql.jdbc.AbstractStatement
connection
Fields inherited from interface org.firebirdsql.jdbc.FirebirdPreparedStatement
TYPE_COMMIT, TYPE_DDL, TYPE_DELETE, TYPE_EXEC_PROCEDURE, TYPE_GET_SEGMENT, TYPE_INSERT, TYPE_PUT_SEGMENT, TYPE_ROLLBACK, TYPE_SAVEPOINT, TYPE_SELECT, TYPE_SELECT_FOR_UPDATE, TYPE_SET_GENERATOR, TYPE_START_TRANS, TYPE_UPDATE
Fields 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
ConstructorsModifierConstructorDescriptionprotected
FBPreparedStatement
(FBConnection connection, String sql, ResultSetBehavior rsBehavior, FBObjectListener.StatementListener statementListener, @Nullable FBObjectListener.BlobListener blobListener, boolean metaDataQuery, boolean standaloneStatement, boolean generatedKeys) Create instance of this class and prepare SQL statement.protected
FBPreparedStatement
(FBConnection connection, ResultSetBehavior rsBehavior, FBObjectListener.StatementListener statementListener, FBObjectListener.BlobListener blobListener) Create instance of this class for the specified result set type and concurrency. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addBatch()
void
void
void
void
close()
void
completeStatement
(CompletionReason reason) Completes this statement withreason
.boolean
execute()
boolean
boolean
boolean
boolean
long
executeQuery
(String sql) int
int
executeUpdate
(String sql) int
executeUpdate
(String sql, int autoGeneratedKeys) int
executeUpdate
(String sql, int[] columnIndex) int
executeUpdate
(String sql, String[] columnNames) protected FBField
getField
(int columnIndex) Factory method for the field access objects@Nullable ResultSetMetaData
protected FieldDescriptor
getParameterDescriptor
(int columnIndex) Returns theFieldDescriptor
of the specified parameter.protected boolean
internalExecute
(boolean sendOutParams) Execute this statement.protected boolean
protected void
notifyStatementCompleted
(boolean success) Notifies statement completion.protected void
Prepare fixed statement and initialize parameters.void
final void
setAsciiStream
(int parameterIndex, @Nullable InputStream x) final void
setAsciiStream
(int parameterIndex, @Nullable InputStream x, int length) final void
setAsciiStream
(int parameterIndex, @Nullable InputStream x, long length) void
setBigDecimal
(int parameterIndex, @Nullable BigDecimal x) void
setBinaryStream
(int parameterIndex, @Nullable InputStream inputStream) void
setBinaryStream
(int parameterIndex, @Nullable InputStream inputStream, int length) void
setBinaryStream
(int parameterIndex, @Nullable InputStream inputStream, long length) void
setBlob
(int parameterIndex, @Nullable InputStream inputStream) void
setBlob
(int parameterIndex, @Nullable InputStream inputStream, long length) void
void
setBoolean
(int parameterIndex, boolean x) void
setByte
(int parameterIndex, byte x) void
setBytes
(int parameterIndex, byte @Nullable [] x) void
setCharacterStream
(int parameterIndex, @Nullable Reader reader) void
setCharacterStream
(int parameterIndex, @Nullable Reader reader, int length) void
setCharacterStream
(int parameterIndex, @Nullable Reader reader, long length) void
void
void
void
void
void
setDouble
(int parameterIndex, double x) void
setFloat
(int parameterIndex, float x) void
setInt
(int parameterIndex, int x) void
setLong
(int parameterIndex, long x) void
setNCharacterStream
(int parameterIndex, @Nullable Reader value) void
setNCharacterStream
(int parameterIndex, @Nullable Reader value, long length) void
void
void
void
setNString
(int parameterIndex, @Nullable String value) void
setNull
(int parameterIndex, int sqlType) void
void
void
void
void
void
void
void
void
setShort
(int parameterIndex, short x) void
void
void
void
void
setTimestamp
(int parameterIndex, @Nullable Timestamp x) void
setTimestamp
(int parameterIndex, @Nullable Timestamp x, @Nullable Calendar cal) void
setUnicodeStream
(int parameterIndex, @Nullable InputStream x, int length) Deprecated.void
Methods inherited from class org.firebirdsql.jdbc.FBStatement
cancel, createBatchUpdateException, createBatchUpdateException, createSpecialResultSet, createStatementListener, enquoteIdentifier, enquoteLiteral, enquoteNCharLiteral, executeBatch, executeImpl, executeLargeBatch, executeLargeUpdate, executeLargeUpdate, executeLargeUpdate, executeLargeUpdate, getCurrentResultSet, getDeletedRowsCount, getExecutionPlan, getExplainedExecutionPlan, getGeneratedKeys, getInsertedRowsCount, getLargeUpdateCount, getLargeUpdateCountMinZero, getMaxFieldSize, getMoreResults, getMoreResults, getQueryTimeout, getResultSet, getResultSet, getStatementHandle, getStatementType, getUpdateCount, getUpdateCountMinZero, getUpdatedRowsCount, hasOpenResultSet, internalExecute, internalExecute, isSimpleIdentifier, isValid, isWrapperFor, nativeSQL, notifyStatementCompleted, notifyStatementStarted, notifyStatementStarted, setEscapeProcessing, setMaxFieldSize, setQueryTimeout, unwrap
Methods inherited from class org.firebirdsql.jdbc.AbstractStatement
addWarning, checkValidity, clearWarnings, closeOnCompletion, completeStatement, equals, fetchConfig, getConnection, getCursorName, getFetchDirection, getFetchSize, getLargeMaxRows, getLocalStatementId, getMaxRows, getResultSetConcurrency, getResultSetHoldability, getResultSetType, getWarnings, hashCode, isClosed, isCloseOnCompletion, isPoolable, performCloseOnCompletion, resultSetBehavior, setCursorName, setFetchDirection, setFetchSize, setLargeMaxRows, setMaxRows, setPoolable, withLock
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.firebirdsql.jdbc.FirebirdPreparedStatement
getStatementType
Methods inherited from interface org.firebirdsql.jdbc.FirebirdStatement
getCurrentResultSet, getDeletedRowsCount, getExecutionPlan, getExplainedExecutionPlan, getInsertedRowsCount, getLastExecutionPlan, getLastExplainedExecutionPlan, getLocalStatementId, getUpdatedRowsCount, hasOpenResultSet, isValid
Methods inherited from interface java.sql.Statement
cancel, clearWarnings, closeOnCompletion, enquoteIdentifier, enquoteLiteral, enquoteNCharLiteral, executeBatch, executeLargeBatch, executeLargeUpdate, executeLargeUpdate, executeLargeUpdate, executeLargeUpdate, 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, setQueryTimeout
Methods inherited from interface java.sql.Wrapper
isWrapperFor, unwrap
-
Field Details
-
METHOD_NOT_SUPPORTED
- See Also:
-
-
Constructor Details
-
FBPreparedStatement
protected FBPreparedStatement(FBConnection connection, ResultSetBehavior rsBehavior, FBObjectListener.StatementListener statementListener, FBObjectListener.BlobListener blobListener) throws SQLException Create instance of this class for the specified result set type and concurrency. This constructor is used only inFBCallableStatement
since the statement is prepared right before the execution.- Parameters:
connection
- connection to be usedrsBehavior
- result set behaviorstatementListener
- statement listener that will be notified about the statement start, close and completionblobListener
- blob listener that will be notified about the statement start and completion- Throws:
SQLException
- if something went wrong.
-
FBPreparedStatement
protected FBPreparedStatement(FBConnection connection, String sql, ResultSetBehavior rsBehavior, FBObjectListener.StatementListener statementListener, @Nullable FBObjectListener.BlobListener blobListener, boolean metaDataQuery, boolean standaloneStatement, boolean generatedKeys) throws SQLException Create instance of this class and prepare SQL statement.- Parameters:
connection
- connection to be usedsql
- SQL statement to preparersBehavior
- result set behaviorstatementListener
- statement listener that will be notified about the statement start, close and completionblobListener
- blob listener that will be notified about the statement start and completionmetaDataQuery
-true
for a metadata query,false
for a normal querystandaloneStatement
-true
for a standalone statement (should only be used whenmetaDataQuery == true
)generatedKeys
-true
if this statement produces a generated keys result set- Throws:
SQLException
- if something went wrong.
-
-
Method Details
-
completeStatement
Description copied from class:AbstractStatement
Completes this statement withreason
.On completion, any open result set will be closed, and possibly the statement itself may be closed.
- Overrides:
completeStatement
in classFBStatement
- Parameters:
reason
- completion reason- Throws:
SQLException
- for failures completing this statement
-
notifyStatementCompleted
Description copied from class:FBStatement
Notifies statement completion.Use of
success = false
should not be generally used for failing execution. The only difference betweentrue
andfalse
is whether completion triggers commit or rollback in auto-commit mode, and in general, even for failed execution, a commit should be triggered. The only exception is for batch execution in auto-commit, where we rollback if one statement failed (and this behaviour is specified by JDBC as implementation-specific), and ending a transaction if statement preparation failed inFBPreparedStatement
.- Overrides:
notifyStatementCompleted
in classFBStatement
- Parameters:
success
-true
notify successful completion,false
for unsuccessful completion- Throws:
SQLException
- exception from handling statement completion (e.g. commit or rollback in auto-commit)
-
executeQuery
- Specified by:
executeQuery
in interfacePreparedStatement
- Throws:
SQLException
-
executeUpdate
- Specified by:
executeUpdate
in interfacePreparedStatement
- Throws:
SQLException
-
close
Description copied from class:AbstractStatement
Subclasses overriding this method are expected to call this method with
super.close()
at an appropriate point to mark it closed.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceStatement
- Overrides:
close
in classFBStatement
- Throws:
SQLException
-
getFirebirdParameterMetaData
- Throws:
SQLException
-
setNull
- Specified by:
setNull
in interfacePreparedStatement
- Throws:
SQLException
-
setBinaryStream
public void setBinaryStream(int parameterIndex, @Nullable InputStream inputStream, int length) throws SQLException - Specified by:
setBinaryStream
in interfacePreparedStatement
- Throws:
SQLException
-
setBinaryStream
public void setBinaryStream(int parameterIndex, @Nullable InputStream inputStream, long length) throws SQLException - Specified by:
setBinaryStream
in interfacePreparedStatement
- Throws:
SQLException
-
setBinaryStream
public void setBinaryStream(int parameterIndex, @Nullable InputStream inputStream) throws SQLException - Specified by:
setBinaryStream
in interfacePreparedStatement
- Throws:
SQLException
-
setBytes
- Specified by:
setBytes
in interfacePreparedStatement
- Throws:
SQLException
-
setBoolean
- Specified by:
setBoolean
in interfacePreparedStatement
- Throws:
SQLException
-
setByte
- Specified by:
setByte
in interfacePreparedStatement
- Throws:
SQLException
-
setDate
- Specified by:
setDate
in interfacePreparedStatement
- Throws:
SQLException
-
setDouble
- Specified by:
setDouble
in interfacePreparedStatement
- Throws:
SQLException
-
setFloat
- Specified by:
setFloat
in interfacePreparedStatement
- Throws:
SQLException
-
setInt
- Specified by:
setInt
in interfacePreparedStatement
- Throws:
SQLException
-
setLong
- Specified by:
setLong
in interfacePreparedStatement
- Throws:
SQLException
-
setObject
- Specified by:
setObject
in interfacePreparedStatement
- Throws:
SQLException
-
setObject
public void setObject(int parameterIndex, @Nullable Object x, SQLType targetSqlType, int scaleOrLength) throws SQLException Implementation note: behaves as
setObject(int, Object, int, int)
called withSQLType.getVendorTypeNumber()
.- Specified by:
setObject
in interfacePreparedStatement
- Throws:
SQLException
-
setObject
public void setObject(int parameterIndex, @Nullable Object x, SQLType targetSqlType) throws SQLException Implementation note: behaves as
setObject(int, Object, int)
called withSQLType.getVendorTypeNumber()
.- Specified by:
setObject
in interfacePreparedStatement
- Throws:
SQLException
-
setShort
- Specified by:
setShort
in interfacePreparedStatement
- Throws:
SQLException
-
setString
- Specified by:
setString
in interfacePreparedStatement
- Throws:
SQLException
-
setTime
- Specified by:
setTime
in interfacePreparedStatement
- Throws:
SQLException
-
setTimestamp
- Specified by:
setTimestamp
in interfacePreparedStatement
- Throws:
SQLException
-
setBigDecimal
- Specified by:
setBigDecimal
in interfacePreparedStatement
- Throws:
SQLException
-
getParameterDescriptor
Returns theFieldDescriptor
of the specified parameter.- Parameters:
columnIndex
- 1-based index of the parameter- Returns:
- Field descriptor
-
getField
Factory method for the field access objects- Throws:
SQLException
-
setAsciiStream
public final void setAsciiStream(int parameterIndex, @Nullable InputStream x, int length) throws SQLException Implementation note: works identical to
setBinaryStream(int, InputStream, int)
.- Specified by:
setAsciiStream
in interfacePreparedStatement
- Throws:
SQLException
-
setAsciiStream
public final void setAsciiStream(int parameterIndex, @Nullable InputStream x, long length) throws SQLException Implementation note: works identical to
setBinaryStream(int, InputStream, long)
.- Specified by:
setAsciiStream
in interfacePreparedStatement
- Throws:
SQLException
-
setAsciiStream
Implementation note: works identical to
setBinaryStream(int, InputStream)
.- Specified by:
setAsciiStream
in interfacePreparedStatement
- Throws:
SQLException
-
setUnicodeStream
@Deprecated(since="1") public void setUnicodeStream(int parameterIndex, @Nullable InputStream x, int length) throws SQLException Deprecated.Method is no longer supported since Jaybird 3.0.For old behavior use
setBinaryStream(int, InputStream, int)
. For JDBC suggested behavior, usesetCharacterStream(int, Reader, int)
.- Specified by:
setUnicodeStream
in interfacePreparedStatement
- Throws:
SQLFeatureNotSupportedException
- AlwaysSQLException
-
setURL
Jaybird does not support array types.
- Specified by:
setURL
in interfacePreparedStatement
- Throws:
SQLException
-
setNCharacterStream
public void setNCharacterStream(int parameterIndex, @Nullable Reader value, long length) throws SQLException Implementation note: This method behaves exactly the same as
setCharacterStream(int, Reader, long)
.- Specified by:
setNCharacterStream
in interfacePreparedStatement
- Throws:
SQLException
-
setNCharacterStream
Implementation note: This method behaves exactly the same as
setCharacterStream(int, Reader)
.- Specified by:
setNCharacterStream
in interfacePreparedStatement
- Throws:
SQLException
-
setNClob
Implementation note: This method behaves exactly the same as
setClob(int, Reader, long)
.- Specified by:
setNClob
in interfacePreparedStatement
- Throws:
SQLException
-
setNClob
Implementation note: This method behaves exactly the same as
setClob(int, Reader)
.- Specified by:
setNClob
in interfacePreparedStatement
- Throws:
SQLException
-
setNString
Implementation note: This method behaves exactly the same as
setString(int, String)
.- Specified by:
setNString
in interfacePreparedStatement
- Throws:
SQLException
-
clearParameters
- Specified by:
clearParameters
in interfacePreparedStatement
- Throws:
SQLException
-
setObject
public void setObject(int parameterIndex, @Nullable Object x, int targetSqlType, int scaleOrLength) throws SQLException Implementation note: ignores
scaleOrLength
andtargetSqlType
and works assetObject(int, Object)
,scaleOrLength
is not ignored ifx
is aReader
orInputStream
.- Specified by:
setObject
in interfacePreparedStatement
- Throws:
SQLException
-
setObject
public void setObject(int parameterIndex, @Nullable Object x, int targetSqlType) throws SQLException Implementation note: ignores
targetSqlType
and works assetObject(int, Object)
.- Specified by:
setObject
in interfacePreparedStatement
- Throws:
SQLException
-
execute
- Specified by:
execute
in interfacePreparedStatement
- Throws:
SQLException
-
internalExecute
Execute this statement. Method checks whether all parameters are set, flushes all "flushable" fields that might contain cached data and executes the statement.- Parameters:
sendOutParams
- Determines if the XSQLDA structure should be sent to the database- Returns:
true
if the statement has more result sets.- Throws:
SQLException
-
isGeneratedKeyQuery
protected boolean isGeneratedKeyQuery()- Overrides:
isGeneratedKeyQuery
in classFBStatement
- Returns:
true
when the current statement is expected to return generated keys,false
otherwise.
-
addBatch
- Specified by:
addBatch
in interfacePreparedStatement
- Throws:
SQLException
-
clearBatch
- Specified by:
clearBatch
in interfaceStatement
- Overrides:
clearBatch
in classFBStatement
- Throws:
SQLException
-
executeBatchInternal
- Overrides:
executeBatchInternal
in classFBStatement
- Throws:
SQLException
-
setCharacterStream
public void setCharacterStream(int parameterIndex, @Nullable Reader reader, int length) throws SQLException - Specified by:
setCharacterStream
in interfacePreparedStatement
- Throws:
SQLException
-
setCharacterStream
public void setCharacterStream(int parameterIndex, @Nullable Reader reader, long length) throws SQLException - Specified by:
setCharacterStream
in interfacePreparedStatement
- Throws:
SQLException
-
setCharacterStream
- Specified by:
setCharacterStream
in interfacePreparedStatement
- Throws:
SQLException
-
setRef
Jaybird does not support ref types.
- Specified by:
setRef
in interfacePreparedStatement
- Throws:
SQLException
-
setBlob
- Specified by:
setBlob
in interfacePreparedStatement
- Throws:
SQLException
-
setBlob
public void setBlob(int parameterIndex, @Nullable InputStream inputStream, long length) throws SQLException - Specified by:
setBlob
in interfacePreparedStatement
- Throws:
SQLException
-
setBlob
- Specified by:
setBlob
in interfacePreparedStatement
- Throws:
SQLException
-
setClob
- Specified by:
setClob
in interfacePreparedStatement
- Throws:
SQLException
-
setClob
- Specified by:
setClob
in interfacePreparedStatement
- Throws:
SQLException
-
setClob
- Specified by:
setClob
in interfacePreparedStatement
- Throws:
SQLException
-
setArray
Jaybird does not support array types.
- Specified by:
setArray
in interfacePreparedStatement
- Throws:
SQLException
-
getMetaData
- Specified by:
getMetaData
in interfacePreparedStatement
- Throws:
SQLException
-
setDate
public void setDate(int parameterIndex, @Nullable Date x, @Nullable Calendar cal) throws SQLException - Specified by:
setDate
in interfacePreparedStatement
- Throws:
SQLException
-
setTime
public void setTime(int parameterIndex, @Nullable Time x, @Nullable Calendar cal) throws SQLException - Specified by:
setTime
in interfacePreparedStatement
- Throws:
SQLException
-
setTimestamp
public void setTimestamp(int parameterIndex, @Nullable Timestamp x, @Nullable Calendar cal) throws SQLException - Specified by:
setTimestamp
in interfacePreparedStatement
- Throws:
SQLException
-
setNull
- Specified by:
setNull
in interfacePreparedStatement
- Throws:
SQLException
-
prepareFixedStatement
Prepare fixed statement and initialize parameters.- Overrides:
prepareFixedStatement
in classFBStatement
- Throws:
SQLException
-
getParameterMetaData
- Specified by:
getParameterMetaData
in interfacePreparedStatement
- Throws:
SQLException
-
setNClob
Implementation note: This method behaves exactly the same as
setClob(int, Clob)
.- Specified by:
setNClob
in interfacePreparedStatement
- Throws:
SQLException
-
setRowId
- Specified by:
setRowId
in interfacePreparedStatement
- Throws:
SQLException
-
setSQLXML
Jaybird does not support SQLXML.
- Specified by:
setSQLXML
in interfacePreparedStatement
- Throws:
SQLException
-
executeQuery
- Specified by:
executeQuery
in interfaceStatement
- Overrides:
executeQuery
in classFBStatement
- Throws:
SQLException
-
executeUpdate
- Specified by:
executeUpdate
in interfaceStatement
- Overrides:
executeUpdate
in classFBStatement
- Throws:
SQLException
-
execute
- Specified by:
execute
in interfaceStatement
- Overrides:
execute
in classFBStatement
- Throws:
SQLException
-
addBatch
- Specified by:
addBatch
in interfaceStatement
- Overrides:
addBatch
in classFBStatement
- Throws:
SQLException
-
executeUpdate
- Specified by:
executeUpdate
in interfaceStatement
- Overrides:
executeUpdate
in classFBStatement
- Throws:
SQLException
-
executeUpdate
- Specified by:
executeUpdate
in interfaceStatement
- Overrides:
executeUpdate
in classFBStatement
- Throws:
SQLException
-
executeUpdate
- Specified by:
executeUpdate
in interfaceStatement
- Overrides:
executeUpdate
in classFBStatement
- Throws:
SQLException
-
execute
- Specified by:
execute
in interfaceStatement
- Overrides:
execute
in classFBStatement
- Throws:
SQLException
-
execute
- Specified by:
execute
in interfaceStatement
- Overrides:
execute
in classFBStatement
- Throws:
SQLException
-
execute
- Specified by:
execute
in interfaceStatement
- Overrides:
execute
in classFBStatement
- Throws:
SQLException
-
executeLargeUpdate
- Specified by:
executeLargeUpdate
in interfacePreparedStatement
- Throws:
SQLException
-