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();
}
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();
}
}
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());
}
}
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();
}
}
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();
}
}
Aggregations