public ReadInitialConnectPacket(final ReadPacketFetcher packetFetcher) throws IOException, QueryException {
  Buffer buffer=packetFetcher.getReusableBuffer();
  if (buffer.getByteAt(0) == Packet.ERROR) {
    ErrorPacket errorPacket=new ErrorPacket(buffer);
    throw new QueryException(errorPacket.getMessage());
  }
  protocolVersion=buffer.readByte();
  serverVersion=buffer.readString(StandardCharsets.US_ASCII);
  serverThreadId=buffer.readInt();
  final byte[] seed1=buffer.readRawBytes(8);
  buffer.skipByte();
  int serverCapabilities2FirstBytes=buffer.readShort();
  serverLanguage=buffer.readByte();
  serverStatus=buffer.readShort();
  int serverCapabilities4FirstBytes=serverCapabilities2FirstBytes + (buffer.readShort() << 16);
  int saltLength=0;
  if ((serverCapabilities4FirstBytes & MariaDbServerCapabilities.PLUGIN_AUTH) != 0) {
    saltLength=Math.max(12,buffer.readByte() - 9);
  }
 else {
    buffer.skipByte();
  }
  buffer.skipBytes(6);
  long mariaDbAdditionalCapacities=buffer.readInt();
  if ((serverCapabilities4FirstBytes & MariaDbServerCapabilities.SECURE_CONNECTION) != 0) {
    final byte[] seed2=buffer.readRawBytes(saltLength);
    seed=Utils.copyWithLength(seed1,seed1.length + seed2.length);
    System.arraycopy(seed2,0,seed,seed1.length,seed2.length);
  }
 else {
    seed=Utils.copyWithLength(seed1,seed1.length);
  }
  buffer.skipByte();
  if ((serverCapabilities4FirstBytes & MariaDbServerCapabilities.PLUGIN_AUTH) != 0) {
    pluginName=buffer.readString(StandardCharsets.US_ASCII);
    if (serverVersion.startsWith(MARIADB_RPL_HACK_PREFIX)) {
      serverCapabilities=(serverCapabilities4FirstBytes & 0xffffffffL) + (mariaDbAdditionalCapacities << 32);
      serverVersion=serverVersion.substring(MARIADB_RPL_HACK_PREFIX.length());
    }
 else {
      serverCapabilities=serverCapabilities4FirstBytes & 0xffffffffL;
    }
  }
 else {
    serverCapabilities=serverCapabilities4FirstBytes & 0xffffffffL;
  }
}

public ReadInitialConnectPacket ( final ReadPacketFetcher packetFetcher ) throws IOException , QueryException { Buffer buffer = packetFetcher . getReusableBuffer ( ) ; if ( buffer . getByteAt ( 0 ) == Packet . ERROR ) { ErrorPacket errorPacket = new ErrorPacket ( buffer ) ; throw new QueryException ( errorPacket . getMessage ( ) ) ; } protocolVersion = buffer . readByte ( ) ; serverVersion = buffer . readString ( StandardCharsets . US_ASCII ) ; serverThreadId = buffer . readInt ( ) ; final byte [ ] seed1 = buffer . readRawBytes ( 8 ) ; buffer . skipByte ( ) ; int serverCapabilities2FirstBytes = buffer . readShort ( ) ; serverLanguage = buffer . readByte ( ) ; serverStatus = buffer . readShort ( ) ; int serverCapabilities4FirstBytes = serverCapabilities2FirstBytes + ( buffer . readShort ( ) << 16 ) ; int saltLength = 0 ; if ( ( serverCapabilities4FirstBytes & MariaDbServerCapabilities . PLUGIN_AUTH ) != 0 ) { saltLength = Math . max ( 12 , buffer . readByte ( ) - 9 ) ; } else { buffer . skipByte ( ) ; } buffer . skipBytes ( 6 ) ; long mariaDbAdditionalCapacities = buffer . readInt ( ) ; if ( ( serverCapabilities4FirstBytes & MariaDbServerCapabilities . SECURE_CONNECTION ) != 0 ) { final byte [ ] seed2 = buffer . readRawBytes ( saltLength ) ; seed = Utils . copyWithLength ( seed1 , seed1 . length + seed2 . length ) ; System . arraycopy ( seed2 , 0 , seed , seed1 . length , seed2 . length ) ; } else { seed = Utils . copyWithLength ( seed1 , seed1 . length ) ; } buffer . skipByte ( ) ; if ( ( serverCapabilities4FirstBytes & MariaDbServerCapabilities . PLUGIN_AUTH ) != 0 ) { pluginName = buffer . readString ( StandardCharsets . US_ASCII ) ; if ( serverVersion . startsWith ( MARIADB_RPL_HACK_PREFIX ) ) { serverCapabilities = ( serverCapabilities4FirstBytes & 0xffffffffL ) + ( mariaDbAdditionalCapacities << 32 ) ; serverVersion = serverVersion . substring ( MARIADB_RPL_HACK_PREFIX . length ( ) ) ; } else { serverCapabilities = serverCapabilities4FirstBytes & 0xffffffffL ; } } else { serverCapabilities = serverCapabilities4FirstBytes & 0xffffffffL ; } }
read database initial stream .
