use of io.mycat.net.mysql.OkPacket in project Mycat-Server by MyCATApache.
the class JDBCConnection method executeddl.
private void executeddl(ServerConnection sc, String sql) throws SQLException {
Statement stmt = null;
try {
stmt = con.createStatement();
int count = stmt.executeUpdate(sql);
OkPacket okPck = new OkPacket();
okPck.affectedRows = count;
okPck.insertId = 0;
okPck.packetId = ++packetId;
okPck.message = " OK!".getBytes();
this.respHandler.okResponse(okPck.writeToBytes(sc), this);
} finally {
if (stmt != null) {
try {
stmt.close();
} catch (SQLException e) {
}
}
}
}
use of io.mycat.net.mysql.OkPacket in project Mycat-Server by MyCATApache.
the class PostgreSQLBackendConnectionHandler method doProcessCommandComplete.
private void doProcessCommandComplete(PostgreSQLBackendConnection con, CommandComplete commandComplete, SelectResponse response) {
if (commandComplete.isSelectComplete()) {
if (response == null) {
throw new RuntimeException("the select proess err ,the SelectResponse is empty");
}
doProcessBusinessQuery(con, response, commandComplete);
} else {
OkPacket okPck = new OkPacket();
okPck.affectedRows = commandComplete.getAffectedRows();
okPck.insertId = commandComplete.getInsertId();
okPck.packetId = ++packetId;
okPck.message = commandComplete.getCommandResponse().getBytes();
con.getResponseHandler().okResponse(okPck.writeToBytes(), con);
}
}
use of io.mycat.net.mysql.OkPacket in project Mycat-Server by MyCATApache.
the class UnLockTablesHandler method okResponse.
@Override
public void okResponse(byte[] data, BackendConnection conn) {
boolean executeResponse = conn.syncAndExcute();
if (executeResponse) {
boolean isEndPack = decrementCountBy(1);
session.releaseConnection(conn);
if (isEndPack) {
if (this.isFail() || session.closed()) {
tryErrorFinished(true);
return;
}
OkPacket ok = new OkPacket();
ok.read(data);
lock.lock();
try {
ok.packetId = ++packetId;
ok.serverStatus = session.getSource().isAutocommit() ? 2 : 1;
} finally {
lock.unlock();
}
ok.write(session.getSource());
}
}
}
use of io.mycat.net.mysql.OkPacket in project Mycat-Server by MyCATApache.
the class KillConnection method response.
public static void response(String stmt, int offset, ManagerConnection mc) {
int count = 0;
List<FrontendConnection> list = getList(stmt, offset, mc);
if (list != null) {
for (NIOConnection c : list) {
StringBuilder s = new StringBuilder();
logger.warn(s.append(c).append("killed by manager").toString());
c.close("kill by manager");
count++;
}
}
OkPacket packet = new OkPacket();
packet.packetId = 1;
packet.affectedRows = count;
packet.serverStatus = 2;
packet.write(mc);
}
use of io.mycat.net.mysql.OkPacket in project Mycat-Server by MyCATApache.
the class ReloadUserStat method execute.
public static void execute(ManagerConnection c) {
Map<String, UserStat> statMap = UserStatAnalyzer.getInstance().getUserStatMap();
for (UserStat userStat : statMap.values()) {
userStat.reset();
}
StringBuilder s = new StringBuilder();
s.append(c).append("Reset show @@sql @@sql.sum @@sql.slow success by manager");
logger.warn(s.toString());
OkPacket ok = new OkPacket();
ok.packetId = 1;
ok.affectedRows = 1;
ok.serverStatus = 2;
ok.message = "Reset show @@sql @@sql.sum @@sql.slow success".getBytes();
ok.write(c);
}
Aggregations