Class Buffer

java.lang.Object
com.mysql.jdbc.Buffer

public class Buffer extends Object
Buffer contains code to read and write packets from/to the MySQL server.
  • Field Details

    • MAX_BYTES_TO_DUMP

      static final int MAX_BYTES_TO_DUMP
      See Also:
    • NO_LENGTH_LIMIT

      static final int NO_LENGTH_LIMIT
      See Also:
    • NULL_LENGTH

      static final long NULL_LENGTH
      See Also:
    • wasMultiPacket

      protected boolean wasMultiPacket
    • TYPE_ID_ERROR

      public static final short TYPE_ID_ERROR
      See Also:
    • TYPE_ID_EOF

      public static final short TYPE_ID_EOF
      See Also:
    • TYPE_ID_AUTH_SWITCH

      public static final short TYPE_ID_AUTH_SWITCH
      It has the same signature as EOF, but may be issued by server only during handshake phase
      See Also:
    • TYPE_ID_LOCAL_INFILE

      public static final short TYPE_ID_LOCAL_INFILE
      See Also:
    • TYPE_ID_OK

      public static final short TYPE_ID_OK
      See Also:
  • Constructor Details

    • Buffer

      public Buffer(byte[] buf)
    • Buffer

      Buffer(int size)
  • Method Details

    • clear

      final void clear()
    • dump

      final void dump()
    • dump

      final String dump(int numBytes)
    • dumpClampedBytes

      final String dumpClampedBytes(int numBytes)
    • dumpHeader

      final void dumpHeader()
    • dumpNBytes

      final void dumpNBytes(int start, int nBytes)
    • ensureCapacity

      final void ensureCapacity(int additionalData) throws SQLException
      Throws:
      SQLException
    • fastSkipLenString

      public int fastSkipLenString()
      Skip over a length-encoded string
      Returns:
      The position past the end of the string
    • fastSkipLenByteArray

      public void fastSkipLenByteArray()
    • getBufferSource

      protected final byte[] getBufferSource()
    • getBufLength

      public int getBufLength()
    • getByteBuffer

      public byte[] getByteBuffer()
      Returns the array of bytes this Buffer is using to read from.
      Returns:
      byte array being read from
    • getBytes

      final byte[] getBytes(int len)
    • getBytes

      byte[] getBytes(int offset, int len)
    • getCapacity

      int getCapacity()
    • getNioBuffer

      public ByteBuffer getNioBuffer()
    • getPosition

      public int getPosition()
      Returns the current position to write to/ read from
      Returns:
      the current position to write to/ read from
    • isEOFPacket

      final boolean isEOFPacket()
    • isAuthMethodSwitchRequestPacket

      final boolean isAuthMethodSwitchRequestPacket()
    • isOKPacket

      final boolean isOKPacket()
    • isResultSetOKPacket

      final boolean isResultSetOKPacket()
    • isRawPacket

      final boolean isRawPacket()
    • newReadLength

      final long newReadLength()
    • readByte

      final byte readByte()
    • readByte

      final byte readByte(int readAt)
    • readFieldLength

      final long readFieldLength()
    • readInt

      final int readInt()
    • readIntAsLong

      final int readIntAsLong()
    • readLenByteArray

      final byte[] readLenByteArray(int offset)
    • readLength

      final long readLength()
    • readLong

      final long readLong()
    • readLongInt

      final int readLongInt()
    • readLongLong

      final long readLongLong()
    • readnBytes

      final int readnBytes()
    • readString

      public final String readString()
    • readString

      final String readString(String encoding, ExceptionInterceptor exceptionInterceptor) throws SQLException
      Read string[NUL]
      Parameters:
      encoding -
      exceptionInterceptor -
      Throws:
      SQLException
    • readString

      final String readString(String encoding, ExceptionInterceptor exceptionInterceptor, int expectedLength) throws SQLException
      Read string[$len]
      Throws:
      SQLException
    • setBufLength

      public void setBufLength(int bufLengthToSet)
    • setByteBuffer

      public void setByteBuffer(byte[] byteBufferToSet)
      Sets the array of bytes to use as a buffer to read from.
      Parameters:
      byteBuffer - the array of bytes to use as a buffer
    • setPosition

      public void setPosition(int positionToSet)
      Set the current position to write to/ read from
      Parameters:
      position - the position (0-based index)
    • setWasMultiPacket

      public void setWasMultiPacket(boolean flag)
      Sets whether this packet was part of a multipacket
      Parameters:
      flag - was this packet part of a multipacket?
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • toSuperString

      public String toSuperString()
    • wasMultiPacket

      public boolean wasMultiPacket()
      Was this packet part of a multipacket?
      Returns:
      was this packet part of a multipacket?
    • writeByte

      public final void writeByte(byte b) throws SQLException
      Throws:
      SQLException
    • writeBytesNoNull

      public final void writeBytesNoNull(byte[] bytes) throws SQLException
      Throws:
      SQLException
    • writeBytesNoNull

      final void writeBytesNoNull(byte[] bytes, int offset, int length) throws SQLException
      Throws:
      SQLException
    • writeDouble

      final void writeDouble(double d) throws SQLException
      Throws:
      SQLException
    • writeFieldLength

      final void writeFieldLength(long length) throws SQLException
      Throws:
      SQLException
    • writeFloat

      final void writeFloat(float f) throws SQLException
      Throws:
      SQLException
    • writeInt

      final void writeInt(int i) throws SQLException
      Throws:
      SQLException
    • writeLenBytes

      final void writeLenBytes(byte[] b) throws SQLException
      Throws:
      SQLException
    • writeLenString

      final void writeLenString(String s, String encoding, String serverEncoding, SingleByteCharsetConverter converter, boolean parserKnowsUnicode, MySQLConnection conn) throws UnsupportedEncodingException, SQLException
      Throws:
      UnsupportedEncodingException
      SQLException
    • writeLong

      final void writeLong(long i) throws SQLException
      Throws:
      SQLException
    • writeLongInt

      final void writeLongInt(int i) throws SQLException
      Throws:
      SQLException
    • writeLongLong

      final void writeLongLong(long i) throws SQLException
      Throws:
      SQLException
    • writeString

      final void writeString(String s) throws SQLException
      Throws:
      SQLException
    • writeString

      final void writeString(String s, String encoding, MySQLConnection conn) throws SQLException
      Throws:
      SQLException
    • writeStringNoNull

      final void writeStringNoNull(String s) throws SQLException
      Throws:
      SQLException
    • writeStringNoNull

      final void writeStringNoNull(String s, String encoding, String serverEncoding, boolean parserKnowsUnicode, MySQLConnection conn) throws UnsupportedEncodingException, SQLException
      Throws:
      UnsupportedEncodingException
      SQLException