Search in sources :

Example 1 with PreparedOkPacket

use of io.mycat.net.mysql.PreparedOkPacket in project Mycat_plus by coderczp.

the class PreparedStmtResponse method response.

public static void response(PreparedStatement pstmt, FrontendConnection c) {
    byte packetId = 0;
    // write preparedOk packet
    PreparedOkPacket preparedOk = new PreparedOkPacket();
    preparedOk.packetId = ++packetId;
    preparedOk.statementId = pstmt.getId();
    preparedOk.columnsNumber = pstmt.getColumnsNumber();
    preparedOk.parametersNumber = pstmt.getParametersNumber();
    ByteBuffer buffer = preparedOk.write(c.allocate(), c, true);
    // write parameter field packet
    int parametersNumber = preparedOk.parametersNumber;
    if (parametersNumber > 0) {
        for (int i = 0; i < parametersNumber; i++) {
            FieldPacket field = new FieldPacket();
            field.packetId = ++packetId;
            buffer = field.write(buffer, c, true);
        }
        EOFPacket eof = new EOFPacket();
        eof.packetId = ++packetId;
        buffer = eof.write(buffer, c, true);
    }
    // write column field packet
    int columnsNumber = preparedOk.columnsNumber;
    if (columnsNumber > 0) {
        for (int i = 0; i < columnsNumber; i++) {
            FieldPacket field = new FieldPacket();
            field.packetId = ++packetId;
            buffer = field.write(buffer, c, true);
        }
        EOFPacket eof = new EOFPacket();
        eof.packetId = ++packetId;
        buffer = eof.write(buffer, c, true);
    }
    // send buffer
    c.write(buffer);
}
Also used : EOFPacket(io.mycat.net.mysql.EOFPacket) PreparedOkPacket(io.mycat.net.mysql.PreparedOkPacket) ByteBuffer(java.nio.ByteBuffer) FieldPacket(io.mycat.net.mysql.FieldPacket)

Example 2 with PreparedOkPacket

use of io.mycat.net.mysql.PreparedOkPacket in project Mycat-Server by MyCATApache.

the class PreparedStmtResponse method response.

public static void response(PreparedStatement pstmt, FrontendConnection c) {
    byte packetId = 0;
    // write preparedOk packet
    PreparedOkPacket preparedOk = new PreparedOkPacket();
    preparedOk.packetId = ++packetId;
    preparedOk.statementId = pstmt.getId();
    preparedOk.columnsNumber = pstmt.getColumnsNumber();
    preparedOk.parametersNumber = pstmt.getParametersNumber();
    ByteBuffer buffer = preparedOk.write(c.allocate(), c, true);
    // write parameter field packet
    int parametersNumber = preparedOk.parametersNumber;
    if (parametersNumber > 0) {
        for (int i = 0; i < parametersNumber; i++) {
            FieldPacket field = new FieldPacket();
            field.packetId = ++packetId;
            buffer = field.write(buffer, c, true);
        }
        EOFPacket eof = new EOFPacket();
        eof.packetId = ++packetId;
        buffer = eof.write(buffer, c, true);
    }
    // write column field packet
    int columnsNumber = preparedOk.columnsNumber;
    if (columnsNumber > 0) {
        for (int i = 0; i < columnsNumber; i++) {
            FieldPacket field = new FieldPacket();
            field.packetId = ++packetId;
            buffer = field.write(buffer, c, true);
        }
        EOFPacket eof = new EOFPacket();
        eof.packetId = ++packetId;
        buffer = eof.write(buffer, c, true);
    }
    // send buffer
    c.write(buffer);
}
Also used : EOFPacket(io.mycat.net.mysql.EOFPacket) PreparedOkPacket(io.mycat.net.mysql.PreparedOkPacket) ByteBuffer(java.nio.ByteBuffer) FieldPacket(io.mycat.net.mysql.FieldPacket)

Aggregations

EOFPacket (io.mycat.net.mysql.EOFPacket)2 FieldPacket (io.mycat.net.mysql.FieldPacket)2 PreparedOkPacket (io.mycat.net.mysql.PreparedOkPacket)2 ByteBuffer (java.nio.ByteBuffer)2