コード例 #1
0
  public NoSubInterceptorWrapper(StatementInterceptor underlyingInterceptor) {
    if (underlyingInterceptor == null) {
      throw new RuntimeException(Messages.getString("NoSubInterceptorWrapper.0"));
    }

    this.underlyingInterceptor = underlyingInterceptor;
  }
コード例 #2
0
ファイル: MysqlaUtils.java プロジェクト: mkaouer/bugcenter
  public static String extractSqlFromPacket(
      String possibleSqlQuery,
      PacketPayload queryPacket,
      int endOfQueryPacketPosition,
      int maxQuerySizeToLog) {
    String extractedSql = null;

    if (possibleSqlQuery != null) {
      if (possibleSqlQuery.length() > maxQuerySizeToLog) {
        StringBuilder truncatedQueryBuf =
            new StringBuilder(possibleSqlQuery.substring(0, maxQuerySizeToLog));
        truncatedQueryBuf.append(Messages.getString("MysqlIO.25"));
        extractedSql = truncatedQueryBuf.toString();
      } else {
        extractedSql = possibleSqlQuery;
      }
    }

    if (extractedSql == null) {
      // This is probably from a client-side prepared statement

      int extractPosition = endOfQueryPacketPosition;

      boolean truncated = false;

      if (endOfQueryPacketPosition > maxQuerySizeToLog) {
        extractPosition = maxQuerySizeToLog;
        truncated = true;
      }

      extractedSql = StringUtils.toString(queryPacket.getByteBuffer(), 1, (extractPosition - 1));

      if (truncated) {
        extractedSql += Messages.getString("MysqlIO.25");
      }
    }

    return extractedSql;
  }