private void readResultSet ( Buffer buffer , Results results ) throws SQLException { long fieldCount = buffer . getLengthEncodedNumeric ( ) ; try { //read columns information's ColumnInformation [ ] ci = new ColumnInformation [ ( int ) fieldCount ] ; for ( int i = 0 ; i < fieldCount ; i ++ ) { ci [ i ] = new ColumnInformation ( reader . getPacket ( false ) ) ; } boolean callableResult = false ; if ( ! eofDeprecated ) { //read EOF packet //EOF status 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 does send the a bad "more result flag" Buffer bufferEof = reader . getPacket ( true ) ; if ( bufferEof . readByte ( ) != EOF ) { //using IOException to close connection, throw new IOException ( "Packets out of order when reading field packets, expected was EOF stream." + ( ( options . enablePacketDebug ) ? getTraces ( ) : "Packet contents (hex) = " + Utils . hexdump ( options . maxQuerySizeToLog , 0 , bufferEof . limit , bufferEof . buf ) ) ) ; } bufferEof . skipBytes ( 2 ) ; //Skip warningCount callableResult = ( bufferEof . readShort ( ) & ServerStatus . PS_OUT_PARAMETERS ) != 0 ; } //read resultSet SelectResultSet selectResultSet ; if ( results . getResultSetConcurrency ( ) == ResultSet . CONCUR_READ_ONLY ) { selectResultSet = new SelectResultSet ( ci , results , this , reader , callableResult , eofDeprecated ) ; } else { //remove fetch size to permit updating results without creating new connection results . removeFetchSize ( ) ; selectResultSet = new UpdatableResultSet ( ci , results , this , reader , callableResult , eofDeprecated ) ; } results . addResultSet ( selectResultSet , hasMoreResults ( ) || results . getFetchSize ( ) > 0 ) ; } catch ( IOException e ) { throw handleIoException ( e ) ; } }
Read ResultSet Packet .