Module io.helidon.integrations.jdbc
Package io.helidon.integrations.jdbc
Class DelegatingStatement<S extends Statement>
java.lang.Object
io.helidon.integrations.jdbc.DelegatingStatement<S>
- Type Parameters:
S
- the type of theStatement
subclass
- All Implemented Interfaces:
AutoCloseable
,Statement
,Wrapper
- Direct Known Subclasses:
DelegatingPreparedStatement
-
Field Summary
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
ConstructorDescriptionDelegatingStatement
(Connection connection, S delegate, boolean closeable, boolean strictClosedChecking) Creates a newDelegatingStatement
. -
Method Summary
Modifier and TypeMethodDescriptionvoid
void
cancel()
protected final void
Ensures thisDelegatingStatement
is not closed, if strict closed checking was enabled at construction time.void
void
void
close()
Overrides theStatement.close()
method so that when it is invoked thisDelegatingStatement
is closed only if it is closeable.void
protected final S
delegate()
Returns theStatement
to which all operations will be delegated.enquoteIdentifier
(String identifier, boolean alwaysQuote) enquoteLiteral
(String val) boolean
boolean
boolean
boolean
int[]
long[]
long
executeLargeUpdate
(String sql) long
executeLargeUpdate
(String sql, int autoGeneratedKeys) long
executeLargeUpdate
(String sql, int[] columnIndexes) long
executeLargeUpdate
(String sql, String[] columnNames) executeQuery
(String sql) int
executeUpdate
(String sql) int
executeUpdate
(String sql, int autoGeneratedKeys) int
executeUpdate
(String sql, int[] columnIndexes) int
executeUpdate
(String sql, String[] columnNames) Returns theConnection
supplied at construction time.int
int
long
long
int
int
boolean
boolean
getMoreResults
(int current) int
int
int
int
int
boolean
boolean
isClosed()
boolean
boolean
boolean
isSimpleIdentifier
(String identifier) boolean
isWrapperFor
(Class<?> iface) void
setCloseable
(boolean closeable) Sets the closeable status of thisDelegatingStatement
.void
setCursorName
(String name) void
setEscapeProcessing
(boolean enable) void
setFetchDirection
(int direction) void
setFetchSize
(int rows) void
setLargeMaxRows
(long max) void
setMaxFieldSize
(int max) void
setMaxRows
(int max) void
setPoolable
(boolean poolable) void
setQueryTimeout
(int seconds) <T> T
-
Constructor Details
-
DelegatingStatement
public DelegatingStatement(Connection connection, S delegate, boolean closeable, boolean strictClosedChecking) Creates a newDelegatingStatement
.- Parameters:
connection
- theConnection
that created thisDelegatingStatement
; must not benull
delegate
- theStatement
instance to which all operations will be delegated; must not benull
closeable
- the initial value for thisDelegatingStatement
's closeable statusstrictClosedChecking
- iftrue
, then thisDelegatingStatement
'sisClosed()
method will be invoked before every operation that cannot take place on a closed statement, and, if it returnstrue
, the operation in question will fail with aSQLException
- Throws:
NullPointerException
- if eitherconnection
ordelegate
isnull
- See Also:
-
-
Method Details
-
delegate
Returns theStatement
to which all operations will be delegated.This method never returns
null
.- Returns:
- the
Statement
to which all operations will be delegated; nevernull
-
isCloseable
Returnstrue
if a call toclose()
will actually close thisDelegatingStatement
.This method returns
true
whensetCloseable(boolean)
has been called with a value oftrue
and theisClosed()
method returnsfalse
.- Returns:
true
if a call toclose()
will actually close thisDelegatingStatement
;false
in all other cases- Throws:
SQLException
- ifisClosed()
throws aSQLException
- See Also:
-
setCloseable
public void setCloseable(boolean closeable) Sets the closeable status of thisDelegatingStatement
.Note that calling this method with a value of
true
does not necessarily mean that theisCloseable()
method will subsequently returntrue
, since theisClosed()
method may returntrue
.- Parameters:
closeable
- whether or not a call toclose()
will actually close thisDelegatingStatement
- See Also:
-
isClosed
- Specified by:
isClosed
in interfaceStatement
- Throws:
SQLException
-
close
Overrides theStatement.close()
method so that when it is invoked thisDelegatingStatement
is closed only if it is closeable.Overrides should normally call
super.close()
as part of their implementation.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceStatement
- Throws:
SQLException
- if an error occurs- See Also:
-
executeQuery
- Specified by:
executeQuery
in interfaceStatement
- Throws:
SQLException
-
executeUpdate
- Specified by:
executeUpdate
in interfaceStatement
- Throws:
SQLException
-
getMaxFieldSize
- Specified by:
getMaxFieldSize
in interfaceStatement
- Throws:
SQLException
-
setMaxFieldSize
- Specified by:
setMaxFieldSize
in interfaceStatement
- Throws:
SQLException
-
getMaxRows
- Specified by:
getMaxRows
in interfaceStatement
- Throws:
SQLException
-
setMaxRows
- Specified by:
setMaxRows
in interfaceStatement
- Throws:
SQLException
-
setEscapeProcessing
- Specified by:
setEscapeProcessing
in interfaceStatement
- Throws:
SQLException
-
getQueryTimeout
- Specified by:
getQueryTimeout
in interfaceStatement
- Throws:
SQLException
-
setQueryTimeout
- Specified by:
setQueryTimeout
in interfaceStatement
- Throws:
SQLException
-
cancel
- Specified by:
cancel
in interfaceStatement
- Throws:
SQLException
-
getWarnings
- Specified by:
getWarnings
in interfaceStatement
- Throws:
SQLException
-
clearWarnings
- Specified by:
clearWarnings
in interfaceStatement
- Throws:
SQLException
-
setCursorName
- Specified by:
setCursorName
in interfaceStatement
- Throws:
SQLException
-
execute
- Specified by:
execute
in interfaceStatement
- Throws:
SQLException
-
getResultSet
- Specified by:
getResultSet
in interfaceStatement
- Throws:
SQLException
-
getUpdateCount
- Specified by:
getUpdateCount
in interfaceStatement
- Throws:
SQLException
-
getMoreResults
- Specified by:
getMoreResults
in interfaceStatement
- Throws:
SQLException
-
setFetchDirection
- Specified by:
setFetchDirection
in interfaceStatement
- Throws:
SQLException
-
getFetchDirection
- Specified by:
getFetchDirection
in interfaceStatement
- Throws:
SQLException
-
setFetchSize
- Specified by:
setFetchSize
in interfaceStatement
- Throws:
SQLException
-
getFetchSize
- Specified by:
getFetchSize
in interfaceStatement
- Throws:
SQLException
-
getResultSetConcurrency
- Specified by:
getResultSetConcurrency
in interfaceStatement
- Throws:
SQLException
-
getResultSetType
- Specified by:
getResultSetType
in interfaceStatement
- Throws:
SQLException
-
addBatch
- Specified by:
addBatch
in interfaceStatement
- Throws:
SQLException
-
clearBatch
- Specified by:
clearBatch
in interfaceStatement
- Throws:
SQLException
-
executeBatch
- Specified by:
executeBatch
in interfaceStatement
- Throws:
SQLException
-
getConnection
Returns theConnection
supplied at construction time.- Specified by:
getConnection
in interfaceStatement
- Returns:
- the
Connection
supplied at construction time; nevernull
- Throws:
SQLException
- not thrown by the default implementation of this method- See Also:
-
getMoreResults
- Specified by:
getMoreResults
in interfaceStatement
- Throws:
SQLException
-
getGeneratedKeys
- Specified by:
getGeneratedKeys
in interfaceStatement
- Throws:
SQLException
-
executeUpdate
- Specified by:
executeUpdate
in interfaceStatement
- Throws:
SQLException
-
executeUpdate
- Specified by:
executeUpdate
in interfaceStatement
- Throws:
SQLException
-
executeUpdate
- Specified by:
executeUpdate
in interfaceStatement
- Throws:
SQLException
-
execute
- Specified by:
execute
in interfaceStatement
- Throws:
SQLException
-
execute
- Specified by:
execute
in interfaceStatement
- Throws:
SQLException
-
execute
- Specified by:
execute
in interfaceStatement
- Throws:
SQLException
-
getResultSetHoldability
- Specified by:
getResultSetHoldability
in interfaceStatement
- Throws:
SQLException
-
setPoolable
- Specified by:
setPoolable
in interfaceStatement
- Throws:
SQLException
-
isPoolable
- Specified by:
isPoolable
in interfaceStatement
- Throws:
SQLException
-
closeOnCompletion
- Specified by:
closeOnCompletion
in interfaceStatement
- Throws:
SQLException
-
isCloseOnCompletion
- Specified by:
isCloseOnCompletion
in interfaceStatement
- Throws:
SQLException
-
getLargeUpdateCount
- Specified by:
getLargeUpdateCount
in interfaceStatement
- Throws:
SQLException
-
setLargeMaxRows
- Specified by:
setLargeMaxRows
in interfaceStatement
- Throws:
SQLException
-
getLargeMaxRows
- Specified by:
getLargeMaxRows
in interfaceStatement
- Throws:
SQLException
-
executeLargeBatch
- Specified by:
executeLargeBatch
in interfaceStatement
- Throws:
SQLException
-
executeLargeUpdate
- Specified by:
executeLargeUpdate
in interfaceStatement
- Throws:
SQLException
-
executeLargeUpdate
- Specified by:
executeLargeUpdate
in interfaceStatement
- Throws:
SQLException
-
executeLargeUpdate
- Specified by:
executeLargeUpdate
in interfaceStatement
- Throws:
SQLException
-
executeLargeUpdate
- Specified by:
executeLargeUpdate
in interfaceStatement
- Throws:
SQLException
-
enquoteLiteral
- Specified by:
enquoteLiteral
in interfaceStatement
- Throws:
SQLException
-
enquoteIdentifier
- Specified by:
enquoteIdentifier
in interfaceStatement
- Throws:
SQLException
-
isSimpleIdentifier
- Specified by:
isSimpleIdentifier
in interfaceStatement
- Throws:
SQLException
-
enquoteNCharLiteral
- Specified by:
enquoteNCharLiteral
in interfaceStatement
- Throws:
SQLException
-
unwrap
- Specified by:
unwrap
in interfaceWrapper
- Throws:
SQLException
-
isWrapperFor
- Specified by:
isWrapperFor
in interfaceWrapper
- Throws:
SQLException
-
checkOpen
Ensures thisDelegatingStatement
is not closed, if strict closed checking was enabled at construction time.If a subclass overrides the
isClosed()
method, the override must not call this method or undefined behavior, such as an infinite loop, may result.This method is intended for advanced use cases only and almost all users of this class will have no reason to call it.
- Throws:
SQLException
- if thisDelegatingStatement
was created with strict closed checking enabled and an invocation of theisClosed()
method returnstrue
, or if some other database access error occurs
-