use of com.actiontech.dble.net.mysql.PreparedOkPacket in project dble by actiontech.
the class PreparedStmtResponse method response.
public static void response(PreparedStatement pStmt, FrontendConnection c) {
byte packetId = 0;
// write preparedOk packet
PreparedOkPacket preparedOk = new PreparedOkPacket();
preparedOk.setPacketId(++packetId);
preparedOk.setStatementId(pStmt.getId());
preparedOk.setColumnsNumber(pStmt.getColumnsNumber());
preparedOk.setParametersNumber(pStmt.getParametersNumber());
ByteBuffer buffer = preparedOk.write(c.allocate(), c, true);
// write parameter field packet
int parametersNumber = preparedOk.getParametersNumber();
if (parametersNumber > 0) {
for (int i = 0; i < parametersNumber; i++) {
FieldPacket field = new FieldPacket();
field.setPacketId(++packetId);
buffer = field.write(buffer, c, true);
}
EOFPacket eof = new EOFPacket();
eof.setPacketId(++packetId);
buffer = eof.write(buffer, c, true);
}
// write column field packet
int columnsNumber = preparedOk.getColumnsNumber();
if (columnsNumber > 0) {
for (int i = 0; i < columnsNumber; i++) {
FieldPacket field = new FieldPacket();
field.setPacketId(++packetId);
buffer = field.write(buffer, c, true);
}
EOFPacket eof = new EOFPacket();
eof.setPacketId(++packetId);
buffer = eof.write(buffer, c, true);
}
// send buffer
c.write(buffer);
}
Aggregations