private boolean readNextValue ( ) throws IOException , SQLException { byte [ ] buf = reader . getPacketArray ( false ) ; //is error Packet if ( buf [ 0 ] == ERROR ) { protocol . removeActiveStreamingResult ( ) ; protocol . removeHasMoreResults ( ) ; protocol . setHasWarnings ( false ) ; ErrorPacket errorPacket = new ErrorPacket ( new Buffer ( buf ) ) ; resetVariables ( ) ; throw ExceptionMapper . get ( errorPacket . getMessage ( ) , errorPacket . getSqlState ( ) , errorPacket . getErrorNumber ( ) , null , false ) ; } //is end of stream if ( buf [ 0 ] == EOF && ( ( eofDeprecated && buf . length < 0xffffff ) || ( ! eofDeprecated && buf . length < 8 ) ) ) { int serverStatus ; int warnings ; if ( ! eofDeprecated ) { //EOF_Packet warnings = ( buf [ 1 ] & 0xff ) + ( ( buf [ 2 ] & 0xff ) << 8 ) ; serverStatus = ( ( buf [ 3 ] & 0xff ) + ( ( buf [ 4 ] & 0xff ) << 8 ) ) ; //CallableResult has been read from intermediate EOF server_status //and is mandatory because : // // - Call query will have an callable resultSet for OUT parameters // this resultSet must be identified and not listed in JDBC statement.getResultSet() // // - after a callable resultSet, a OK packet is send, // but mysql before 5.7.4 doesn't send MORE_RESULTS_EXISTS flag if ( callableResult ) { serverStatus |= MORE_RESULTS_EXISTS ; } } else { //OK_Packet with a 0xFE header int pos = skipLengthEncodedValue ( buf , 1 ) ; //skip update count pos = skipLengthEncodedValue ( buf , pos ) ; //skip insert id serverStatus = ( ( buf [ pos ++ ] & 0xff ) + ( ( buf [ pos ++ ] & 0xff ) << 8 ) ) ; warnings = ( buf [ pos ++ ] & 0xff ) + ( ( buf [ pos ] & 0xff ) << 8 ) ; callableResult = ( serverStatus & PS_OUT_PARAMETERS ) != 0 ; } protocol . setServerStatus ( ( short ) serverStatus ) ; protocol . setHasWarnings ( warnings > 0 ) ; if ( ( serverStatus & MORE_RESULTS_EXISTS ) == 0 ) { protocol . removeActiveStreamingResult ( ) ; } resetVariables ( ) ; return false ; } //this is a result-set row, save it if ( dataSize + 1 >= data . length ) { growDataArray ( ) ; } data [ dataSize ++ ] = buf ; return true ; }
Read next value .