Search in sources :

Example 16 with MySQLPayloadWriter

use of io.mycat.beans.mysql.MySQLPayloadWriter in project Mycat2 by MyCATApache.

the class BinaryResultSetResponse method converBit.

public static byte[] converBit(Object object) {
    byte[] bytes;
    if (object instanceof byte[]) {
        bytes = (byte[]) object;
    } else if (object instanceof Boolean) {
        long i = (Boolean) object ? 1 : 0;
        bytes = new byte[] { (byte) i };
    } else if (object instanceof Number) {
        long i = ((Number) object).longValue();
        bytes = ByteUtil.getBytes((long) i);
    } else {
        bytes = object.toString().getBytes();
    }
    MySQLPayloadWriter mySQLPayloadWriter = new MySQLPayloadWriter(bytes.length);
    mySQLPayloadWriter.writeLenencBytes(bytes);
    return mySQLPayloadWriter.toByteArray();
}
Also used : MySQLPayloadWriter(io.mycat.beans.mysql.MySQLPayloadWriter)

Example 17 with MySQLPayloadWriter

use of io.mycat.beans.mysql.MySQLPayloadWriter in project Mycat2 by MyCATApache.

the class MySQLPacketUtil method generateLondData.

public static final byte[] generateLondData(long statementId, long paramId, byte[] data) {
    try (MySQLPayloadWriter out = new MySQLPayloadWriter(data.length + 8 + 8)) {
        out.write(0x18);
        out.writeFixInt(4, statementId);
        out.writeFixInt(2, paramId);
        out.write(data);
        return out.toByteArray();
    }
}
Also used : MySQLPayloadWriter(io.mycat.beans.mysql.MySQLPayloadWriter)

Example 18 with MySQLPayloadWriter

use of io.mycat.beans.mysql.MySQLPayloadWriter in project Mycat2 by MyCATApache.

the class MySQLPacketUtil method generateClosePacket.

public static final byte[] generateClosePacket(long statementId) {
    try (MySQLPayloadWriter writer = new MySQLPayloadWriter(5)) {
        writer.write(0x19);
        writer.writeFixInt(4, statementId);
        return generateMySQLPacket(0, writer.toByteArray());
    }
}
Also used : MySQLPayloadWriter(io.mycat.beans.mysql.MySQLPayloadWriter)

Example 19 with MySQLPayloadWriter

use of io.mycat.beans.mysql.MySQLPayloadWriter in project Mycat2 by MyCATApache.

the class MySQLPacketUtil method generateExecutePayload.

public static final byte[] generateExecutePayload(long statementId, byte flags, int numParams, byte[] rest) {
    final long iteration = 1;
    try (MySQLPayloadWriter mySQLPacket = new MySQLPayloadWriter(64)) {
        mySQLPacket.writeByte((byte) 0x17);
        mySQLPacket.writeFixInt(4, statementId);
        mySQLPacket.writeByte(flags);
        mySQLPacket.writeFixInt(4, iteration);
        mySQLPacket.writeBytes(rest);
        return mySQLPacket.toByteArray();
    }
}
Also used : MySQLPayloadWriter(io.mycat.beans.mysql.MySQLPayloadWriter)

Example 20 with MySQLPayloadWriter

use of io.mycat.beans.mysql.MySQLPayloadWriter in project Mycat2 by MyCATApache.

the class MySQLPacketUtil method generateComQueryPayload.

public static final byte[] generateComQueryPayload(byte[] sql) {
    try (MySQLPayloadWriter writer = new MySQLPayloadWriter(sql.length + 5)) {
        writer.write(0x3);
        writer.writeEOFStringBytes(sql);
        return writer.toByteArray();
    }
}
Also used : MySQLPayloadWriter(io.mycat.beans.mysql.MySQLPayloadWriter)

Aggregations

MySQLPayloadWriter (io.mycat.beans.mysql.MySQLPayloadWriter)31 UnsupportedEncodingException (java.io.UnsupportedEncodingException)4 MycatMySQLRowMetaData (io.mycat.beans.mycat.MycatMySQLRowMetaData)2 AuthPacket (io.mycat.beans.mysql.packet.AuthPacket)2 AuthSwitchRequestPacket (io.mycat.beans.mysql.packet.AuthSwitchRequestPacket)2 Authenticator (io.mycat.Authenticator)1 MycatUser (io.mycat.MycatUser)1 HandshakePacket (io.mycat.beans.mysql.packet.HandshakePacket)1 MySQLPacket (io.mycat.beans.mysql.packet.MySQLPacket)1 MySQLServerCapabilityFlags (io.mycat.config.MySQLServerCapabilityFlags)1 UserConfig (io.mycat.config.UserConfig)1 Buffer (io.vertx.core.buffer.Buffer)1 SocketAddress (java.net.SocketAddress)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1