use of com.alibaba.cobar.exception.ErrorPacketException in project cobar by alibaba.
the class MySQLChannel method sendCharset.
/**
* 发送字符集设置
*/
private void sendCharset(int ci) throws IOException {
// 发送命令: 直接写入到out中即可
CommandPacket cmd = getCharsetCommand(ci);
cmd.write(out);
out.flush();
BinaryPacket bin = receive();
switch(bin.data[0]) {
case OkPacket.FIELD_COUNT:
this.charsetIndex = ci;
this.charset = CharsetUtil.getCharset(ci);
this.dbCharset = CharsetUtil.getCharset(ci);
break;
case ErrorPacket.FIELD_COUNT:
ErrorPacket err = new ErrorPacket();
err.read(bin);
throw new ErrorPacketException(new String(err.message, charset));
default:
throw new UnknownPacketException(bin.toString());
}
}
Aggregations