public StatusSync(
     MySQLConnection conn, RouteResultsetNode rrn, ServerConnection sc, boolean autocommit) {
   this.conn = conn;
   this.rrn = rrn;
   this.charIndex = sc.getCharsetIndex();
   this.charCmd = conn.charsetIndex != charIndex ? getCharsetCommand(charIndex) : null;
   this.txIsolation = sc.getTxIsolation();
   this.isoCmd = conn.txIsolation != txIsolation ? getTxIsolationCommand(txIsolation) : null;
   this.autocommit = autocommit;
   this.acCmd =
       conn.autocommit != autocommit ? (autocommit ? _AUTOCOMMIT_ON : _AUTOCOMMIT_OFF) : null;
 }
Beispiel #2
0
 private static String responseMessage(String action, ServerConnection c, long id) {
   return new StringBuilder("RESPONSE:")
       .append(action)
       .append(", id=")
       .append(id)
       .append(", host=")
       .append(c.getHost())
       .append(", port=")
       .append(c.getPort())
       .append(", time=")
       .append(TimeUtil.currentTimeMillis())
       .toString();
 }
 @Override
 public void execute(byte[] data) {
   long pstmtId = ByteUtil.readUB4(data, 5);
   PreparedStatement pstmt = null;
   if ((pstmt = pstmtForSql.get(pstmtId)) == null) {
     source.writeErrMessage(
         ErrorCode.ER_ERROR_WHEN_EXECUTING_COMMAND, "Unknown pstmtId when executing.");
   } else {
     ExecutePacket packet = new ExecutePacket(pstmt);
     try {
       packet.read(data, source.getCharset());
     } catch (UnsupportedEncodingException e) {
       source.writeErrMessage(ErrorCode.ER_ERROR_WHEN_EXECUTING_COMMAND, e.getMessage());
       return;
     }
     // TODO ...
   }
 }
Beispiel #4
0
 public static void handle(String stmt, ServerConnection c, int offset) {
   switch (ServerParseStart.parse(stmt, offset)) {
     case ServerParseStart.TRANSACTION:
       if (c.isAutocommit()) {
         c.setAutocommit(false);
         c.write(c.writeToBuffer(AC_OFF, c.allocate()));
       } else {
         c.getSession2().commit();
       }
       break;
     default:
       c.execute(stmt, ServerParse.START);
   }
 }