#https://github.com/sea-boat/mysql-protocol
概況ColumnCount套件屬於服務端傳回ResultSet時的其中一部分套件。
mysql通訊封包結構類型
###名字######描述########## #########int<3>######payload長度#######按照the least significant byte first存儲,3個字節的payload和1個字節的序號組合成報文頭############int<1>#######序號####################string ######payload######報文體,長度為前面指定的payload長度###############ColumnCount套件######### ###Payload#########Protocol::LengthEncodedInteger
/** * * <pre class="brush:php;toolbar:false"><b>column count packet.</b>* @author *
seaboat*
<b>email: </b>849586227@qq.com*
<b>blog: </b>http://www.php.cn/;/pre> * @version 1.0 * @see http://www.php.cn/ */public class ColumnCountPacket extends MySQLPacket { public int columnCount; public void read(byte[] data) { MySQLMessage mm = new MySQLMessage(data); this.packetLength = mm.readUB3(); this.packetId = mm.read(); this.columnCount = (int) mm.readLength(); } @Override public void write(ByteBuffer buffer) { int size = calcPacketSize(); BufferUtil.writeUB3(buffer, size); buffer.put(packetId); BufferUtil.writeLength(buffer, columnCount); } @Override public int calcPacketSize() { int size = BufferUtil.getLength(columnCount); return size; } @Override protected String getPacketInfo() { return "MySQL Column Count Packet"; } }