Package org.mariadb.jdbc.message.server
Class CachedPrepareResultPacket
- java.lang.Object
-
- org.mariadb.jdbc.message.server.PrepareResultPacket
-
- org.mariadb.jdbc.message.server.CachedPrepareResultPacket
-
- All Implemented Interfaces:
Completion
,Prepare
,ServerMessage
public final class CachedPrepareResultPacket extends PrepareResultPacket
Prepare packet result with flag indicating use
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.concurrent.atomic.AtomicBoolean
cached
private java.util.concurrent.atomic.AtomicBoolean
closing
private java.util.List<BasePreparedStatement>
statements
-
Fields inherited from class org.mariadb.jdbc.message.server.PrepareResultPacket
CONSTANT_PARAMETER, statementId
-
-
Constructor Summary
Constructors Constructor Description CachedPrepareResultPacket(ReadableByteBuf buffer, Reader reader, Context context)
Cache prepare result with flag indicating use
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
cache()
indicate that result is in LRU cachevoid
close(Client con)
Indicate that a prepare statement must be closed (if not in LRU cache)void
decrementUse(Client con, BasePreparedStatement preparedStatement)
Decrement use of prepare packet, so closing it if last usedint
getStatementId()
Return prepare statement id.void
incrementUse(BasePreparedStatement preparedStatement)
Increment use of prepare statement.void
reset()
Resetting cache in case of failovervoid
unCache(Client con)
Indicate that Prepare command is not on LRU cache anymore.-
Methods inherited from class org.mariadb.jdbc.message.server.PrepareResultPacket
getColumns, getParameters, setColumns
-
-
-
-
Field Detail
-
closing
private final java.util.concurrent.atomic.AtomicBoolean closing
-
cached
private final java.util.concurrent.atomic.AtomicBoolean cached
-
statements
private final java.util.List<BasePreparedStatement> statements
-
-
Constructor Detail
-
CachedPrepareResultPacket
public CachedPrepareResultPacket(ReadableByteBuf buffer, Reader reader, Context context) throws java.io.IOException
Cache prepare result with flag indicating use- Parameters:
buffer
- prepare packet bufferreader
- packet readercontext
- connection context- Throws:
java.io.IOException
- if any socket error occurs
-
-
Method Detail
-
close
public void close(Client con) throws java.sql.SQLException
Indicate that a prepare statement must be closed (if not in LRU cache)- Specified by:
close
in interfacePrepare
- Overrides:
close
in classPrepareResultPacket
- Parameters:
con
- current connection- Throws:
java.sql.SQLException
- if SQL
-
decrementUse
public void decrementUse(Client con, BasePreparedStatement preparedStatement) throws java.sql.SQLException
Description copied from class:PrepareResultPacket
Decrement use of prepare packet, so closing it if last used- Specified by:
decrementUse
in interfacePrepare
- Overrides:
decrementUse
in classPrepareResultPacket
- Parameters:
con
- connectionpreparedStatement
- current prepared statement that was using prepare object- Throws:
java.sql.SQLException
- if exception occurs
-
incrementUse
public void incrementUse(BasePreparedStatement preparedStatement)
Increment use of prepare statement.- Parameters:
preparedStatement
- new statement using prepare result
-
unCache
public void unCache(Client con)
Indicate that Prepare command is not on LRU cache anymore. closing prepare command if not used- Parameters:
con
- current connection
-
cache
public boolean cache()
indicate that result is in LRU cache- Returns:
- true if cached
-
getStatementId
public int getStatementId()
Return prepare statement id.- Specified by:
getStatementId
in interfacePrepare
- Overrides:
getStatementId
in classPrepareResultPacket
- Returns:
- statement id
-
reset
public void reset()
Resetting cache in case of failover
-
-