Search in sources :

Example 1 with OKPacket

use of com.alibaba.otter.canal.parse.driver.mysql.packets.server.OKPacket in project canal by alibaba.

the class MysqlUpdateExecutor method update.

public OKPacket update(String updateString) throws IOException {
    QueryCommandPacket cmd = new QueryCommandPacket();
    cmd.setQueryString(updateString);
    byte[] bodyBytes = cmd.toBytes();
    PacketManager.write(channel, bodyBytes);
    logger.debug("read update result...");
    byte[] body = PacketManager.readBytes(channel, PacketManager.readHeader(channel, 4).getPacketBodyLength());
    if (body[0] < 0) {
        ErrorPacket packet = new ErrorPacket();
        packet.fromBytes(body);
        throw new IOException(packet + "\n with command: " + updateString);
    }
    OKPacket packet = new OKPacket();
    packet.fromBytes(body);
    return packet;
}
Also used : QueryCommandPacket(com.alibaba.otter.canal.parse.driver.mysql.packets.client.QueryCommandPacket) ErrorPacket(com.alibaba.otter.canal.parse.driver.mysql.packets.server.ErrorPacket) IOException(java.io.IOException) OKPacket(com.alibaba.otter.canal.parse.driver.mysql.packets.server.OKPacket)

Aggregations

QueryCommandPacket (com.alibaba.otter.canal.parse.driver.mysql.packets.client.QueryCommandPacket)1 ErrorPacket (com.alibaba.otter.canal.parse.driver.mysql.packets.server.ErrorPacket)1 OKPacket (com.alibaba.otter.canal.parse.driver.mysql.packets.server.OKPacket)1 IOException (java.io.IOException)1