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:
  `org.mariadb.jdbc.client.Completion`, `Prepare`, `org.mariadb.jdbc.message.ServerMessage`

    public final class CachedPrepareResultPacket
    extends PrepareResultPacket

Prepare packet result with flag indicating use

### Field Summary

### Fields inherited from class org.mariadb.jdbc.message.server.PrepareResultPacket

`statementId`

### Constructor Summary

Constructors
`CachedPrepareResultPacket​(org.mariadb.jdbc.client.ReadableByteBuf buffer, Reader reader, org.mariadb.jdbc.client.Context context)` Cache prepare result with flag indicating use

### Method Summary

All Methods Instance Methods Concrete Methods
`boolean` `cache()` indicate that result is in LRU cache
`void` `close​(org.mariadb.jdbc.client.Client con)` Indicate that a prepare statement must be closed (if not in LRU cache)
`void` `decrementUse​(org.mariadb.jdbc.client.Client con, ServerPreparedStatement preparedStatement)` Decrement use of prepare packet, so closing it if last used
`int` `getStatementId()` Return prepare statement id.
`void` `incrementUse​(ServerPreparedStatement preparedStatement)` Increment use of prepare statement.
`void` `reset()` Resetting cache in case of failover
`void` `unCache​(org.mariadb.jdbc.client.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`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### CachedPrepareResultPacket

    public CachedPrepareResultPacket​(org.mariadb.jdbc.client.ReadableByteBuf buffer,
                                     Reader reader,
                                     org.mariadb.jdbc.client.Context context)
                              throws IOException

Cache prepare result with flag indicating use

Parameters:
  `buffer` - prepare packet buffer
  `reader` - packet reader
  `context` - connection context
Throws:
  `IOException` - if any socket error occurs

### Method Detail

#### close

    public void close​(org.mariadb.jdbc.client.Client con)
               throws SQLException

Indicate that a prepare statement must be closed (if not in LRU cache)

Specified by:
  `close` in interface `Prepare`
Overrides:
  `close` in class `PrepareResultPacket`
Parameters:
  `con` - current connection
Throws:
  `SQLException` - if SQL

#### decrementUse

    public void decrementUse​(org.mariadb.jdbc.client.Client con,
                             ServerPreparedStatement preparedStatement)
                      throws SQLException

Description copied from class: `PrepareResultPacket`
Decrement use of prepare packet, so closing it if last used

Specified by:
  `decrementUse` in interface `Prepare`
Overrides:
  `decrementUse` in class `PrepareResultPacket`
Parameters:
  `con` - connection
  `preparedStatement` - current prepared statement that was using prepare object
Throws:
  `SQLException` - if exception occurs

#### incrementUse

    public void incrementUse​(ServerPreparedStatement preparedStatement)

Increment use of prepare statement.

Parameters:
  `preparedStatement` - new statement using prepare result

#### unCache

    public void unCache​(org.mariadb.jdbc.client.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 interface `Prepare`
Overrides:
  `getStatementId` in class `PrepareResultPacket`
Returns:
  statement id

#### reset

    public void reset()

Resetting cache in case of failover