Package com.mysql.jdbc.profiler

Examples of com.mysql.jdbc.profiler.ProfilerEvent


          && (this.refresher == null) && (this.updater == null)) {
        this.eventSink = ProfilerEventHandlerFactory.getInstance(this.connection);

        String message = Messages.getString("UpdatableResultSet.34"); //$NON-NLS-1$

        this.eventSink.consumeEvent(new ProfilerEvent(
            ProfilerEvent.TYPE_WARN,
            "", //$NON-NLS-1$
            (this.owningStatement == null) ? "N/A" //$NON-NLS-1$
                : this.owningStatement.currentCatalog, //$NON-NLS-1$
            this.connectionId,
View Full Code Here


      Object possibleProfilerEvent) {

    if (possibleProfilerEvent instanceof ProfilerEvent) {
      StringBuffer msgBuf = new StringBuffer();

      ProfilerEvent evt = (ProfilerEvent) possibleProfilerEvent;

      String locationInformation = evt.getEventCreationPointAsString();

      if (locationInformation == null) {
        locationInformation = Util.stackTraceToString(new Throwable());
      }

      msgBuf.append("Profiler Event: [");

      switch (evt.getEventType()) {
      case ProfilerEvent.TYPE_EXECUTE:
        msgBuf.append("EXECUTE");

        break;

      case ProfilerEvent.TYPE_FETCH:
        msgBuf.append("FETCH");

        break;

      case ProfilerEvent.TYPE_OBJECT_CREATION:
        msgBuf.append("CONSTRUCT");

        break;

      case ProfilerEvent.TYPE_PREPARE:
        msgBuf.append("PREPARE");

        break;

      case ProfilerEvent.TYPE_QUERY:
        msgBuf.append("QUERY");

        break;

      case ProfilerEvent.TYPE_WARN:
        msgBuf.append("WARN");

        break;
       
      case ProfilerEvent.TYPE_SLOW_QUERY:
        msgBuf.append("SLOW QUERY");

        break;
       
      default:
        msgBuf.append("UNKNOWN");
      }

      msgBuf.append("] ");
      msgBuf.append(locationInformation);
      msgBuf.append(" duration: ");
      msgBuf.append(evt.getEventDuration());
      msgBuf.append(" ");
      msgBuf.append(evt.getDurationUnits());
      msgBuf.append(", connection-id: ");
      msgBuf.append(evt.getConnectionId());
      msgBuf.append(", statement-id: ");
      msgBuf.append(evt.getStatementId());
      msgBuf.append(", resultset-id: ");
      msgBuf.append(evt.getResultSetId());

      String evtMessage = evt.getMessage();

      if (evtMessage != null) {
        msgBuf.append(", message: ");
        msgBuf.append(evtMessage);
      }
View Full Code Here

        if (this.profileSql) {
            fetchEndTime = System.currentTimeMillis();

            ProfileEventSink eventSink = ProfileEventSink.getInstance(this.connection);

            eventSink.consumeEvent(new ProfilerEvent(ProfilerEvent.TYPE_QUERY,
                    "", catalog, this.connection.getId(), //$NON-NLS-1$
                    (callingStatement != null) ? callingStatement.getId() : 999,
                    rs.resultId, System.currentTimeMillis(),
                    (int) (queryEndTime - queryStartTime), null,
                    new Throwable(), profileQueryToLog));

            eventSink.consumeEvent(new ProfilerEvent(ProfilerEvent.TYPE_FETCH,
                    "", catalog, this.connection.getId(), //$NON-NLS-1$
                    (callingStatement != null) ? callingStatement.getId() : 999,
                    rs.resultId, System.currentTimeMillis(),
                    (int) (fetchEndTime - fetchBeginTime), null,
                    new Throwable(), null));

            if (this.queryBadIndexUsed) {
                eventSink.consumeEvent(new ProfilerEvent(
                        ProfilerEvent.TYPE_WARN, "", catalog, //$NON-NLS-1$
                        this.connection.getId(),
                        (callingStatement != null) ? callingStatement.getId()
                                                   : 999, rs.resultId,
                        System.currentTimeMillis(),
                        (int) (queryEndTime - queryStartTime), null,
                        new Throwable(),
                        Messages.getString("MysqlIO.33") //$NON-NLS-1$
                         +profileQueryToLog));
            }

            if (this.queryNoIndexUsed) {
                eventSink.consumeEvent(new ProfilerEvent(
                        ProfilerEvent.TYPE_WARN, "", catalog, //$NON-NLS-1$
                        this.connection.getId(),
                        (callingStatement != null) ? callingStatement.getId()
                                                   : 999, rs.resultId,
                        System.currentTimeMillis(),
View Full Code Here

    for (int i = 0; i < typesWithNoParseConversion.length; i++) {
      message.append(MysqlDefs.typeToName(typesWithNoParseConversion[i]));
      message.append("\n");
    }

    this.eventSink.consumeEvent(new ProfilerEvent(ProfilerEvent.TYPE_WARN,
        "", (this.owningStatement == null) ? "N/A"
            : this.owningStatement.currentCatalog, this.connection
            .getId(), (this.owningStatement == null) ? (-1)
            : this.owningStatement.getId(), this.resultId, System
            .currentTimeMillis(), 0, null, this.pointOfOrigin,
View Full Code Here

          String message = Messages
              .getString("ResultSet.ResultSet_implicitly_closed_by_driver._150") //$NON-NLS-1$
              + Messages
                  .getString("ResultSet._n_nYou_should_close_ResultSets_explicitly_from_your_code_to_free_up_resources_in_a_more_efficient_manner._151"); //$NON-NLS-1$

          this.eventSink.consumeEvent(new ProfilerEvent(
              ProfilerEvent.TYPE_WARN, "",
              (this.owningStatement == null) ? "N/A"
                  : this.owningStatement.currentCatalog,
              this.connection.getId(),
              (this.owningStatement == null) ? (-1)
                  : this.owningStatement.getId(),
              this.resultId, System.currentTimeMillis(), 0, null,
              this.pointOfOrigin, message));
        }

        if (this.rowData instanceof RowDataStatic && !isLast()
            && !isAfterLast() && (this.rowData.size() != 0)) {
          StringBuffer messageBuf = new StringBuffer(
              Messages
                  .getString("ResultSet.Possible_incomplete_traversal_of_result_set._Cursor_was_left_on_row__154")); //$NON-NLS-1$
          messageBuf.append(getRow());
          messageBuf.append(Messages.getString("ResultSet._of__155")); //$NON-NLS-1$
          messageBuf.append(this.rowData.size());
          messageBuf
              .append(Messages
                  .getString("ResultSet._rows_when_it_was_closed._156")); //$NON-NLS-1$
          messageBuf
              .append(Messages
                  .getString("ResultSet._n_nYou_should_consider_re-formulating_your_query_to_return_only_the_rows_you_are_interested_in_using._157")); //$NON-NLS-1$

          this.eventSink.consumeEvent(new ProfilerEvent(
              ProfilerEvent.TYPE_WARN, "",
              (this.owningStatement == null) ? Messages
                  .getString("ResultSet.N/A_159")
                  : this.owningStatement.currentCatalog, //$NON-NLS-1$
              this.connection.getId(),
              (this.owningStatement == null) ? (-1)
                  : this.owningStatement.getId(),
              this.resultId, System.currentTimeMillis(), 0, null,
              this.pointOfOrigin, messageBuf.toString()));
        }

        //
        // Report on any columns that were selected but
        // not referenced
        //
        if (this.columnUsed.length > 0) {
          StringBuffer buf = new StringBuffer(
              Messages
                  .getString("ResultSet.The_following_columns_were__160")); //$NON-NLS-1$
          buf
              .append(Messages
                  .getString("ResultSet._part_of_the_SELECT_statement_for_this_result_set,_but_were_161")); //$NON-NLS-1$
          buf.append(Messages
              .getString("ResultSet._never_referenced___162")); //$NON-NLS-1$

          boolean issueWarn = false;

          for (int i = 0; i < this.columnUsed.length; i++) {
            if (!this.columnUsed[i]) {
              if (!issueWarn) {
                issueWarn = true;
              } else {
                buf.append(", ");
              }

              buf.append(this.fields[i].getFullName());
            }
          }

          if (issueWarn) {
            this.eventSink.consumeEvent(new ProfilerEvent(
                ProfilerEvent.TYPE_WARN, "",
                (this.owningStatement == null) ? "N/A"
                    : this.owningStatement.currentCatalog,
                this.connection.getId(),
                (this.owningStatement == null) ? (-1)
View Full Code Here

          ProfileEventSink eventSink = ProfileEventSink
              .getInstance(conn);

          eventSink
              .consumeEvent(new ProfilerEvent(
                  ProfilerEvent.TYPE_WARN,
                  "", //$NON-NLS-1$
                  this.owner.owningStatement == null ? "N/A" : this.owner.owningStatement.currentCatalog, //$NON-NLS-1$
                  conn.getId(),
                  this.owner.owningStatement == null ? -1
View Full Code Here

      Object possibleProfilerEvent) {

    if (possibleProfilerEvent instanceof ProfilerEvent) {
      StringBuffer msgBuf = new StringBuffer();

      ProfilerEvent evt = (ProfilerEvent) possibleProfilerEvent;

      Throwable locationException = evt.getEventCreationPoint();

      if (locationException == null) {
        locationException = new Throwable();
      }

      msgBuf.append("Profiler Event: [");

      boolean appendLocationInfo = false;
     
      switch (evt.getEventType()) {
      case ProfilerEvent.TYPE_EXECUTE:
        msgBuf.append("EXECUTE");

        break;

      case ProfilerEvent.TYPE_FETCH:
        msgBuf.append("FETCH");

        break;

      case ProfilerEvent.TYPE_OBJECT_CREATION:
        msgBuf.append("CONSTRUCT");

        break;

      case ProfilerEvent.TYPE_PREPARE:
        msgBuf.append("PREPARE");

        break;

      case ProfilerEvent.TYPE_QUERY:
        msgBuf.append("QUERY");

        break;

      case ProfilerEvent.TYPE_WARN:
        msgBuf.append("WARN");
        appendLocationInfo = true;
       
        break;

      default:
        msgBuf.append("UNKNOWN");
      }

      msgBuf.append("] ");
      msgBuf.append(findCallingClassAndMethod(locationException));
      msgBuf.append(" duration: ");
      msgBuf.append(evt.getEventDurationMillis());
      msgBuf.append(" ms, connection-id: ");
      msgBuf.append(evt.getConnectionId());
      msgBuf.append(", statement-id: ");
      msgBuf.append(evt.getStatementId());
      msgBuf.append(", resultset-id: ");
      msgBuf.append(evt.getResultSetId());

      String evtMessage = evt.getMessage();

      if (evtMessage != null) {
        msgBuf.append(", message: ");
        msgBuf.append(evtMessage);
      }
View Full Code Here

          && (this.refresher == null) && (this.updater == null)) {
        this.eventSink = ProfileEventSink.getInstance(this.connection);

        String message = Messages.getString("UpdatableResultSet.34"); //$NON-NLS-1$

        this.eventSink.consumeEvent(new ProfilerEvent(
            ProfilerEvent.TYPE_WARN, "", //$NON-NLS-1$
            (this.owningStatement == null) ? "N/A" //$NON-NLS-1$
                : this.owningStatement.currentCatalog, //$NON-NLS-1$
            this.connection.getId(),
            (this.owningStatement == null) ? (-1)
View Full Code Here

        if (getUseUsageAdvisor()) {
          if (!calledExplicitly) {
            String message = "Connection implicitly closed by Driver. You should call Connection.close() from your code to free resources more efficiently and avoid resource leaks.";

            this.eventSink.consumeEvent(new ProfilerEvent(
                ProfilerEvent.TYPE_WARN, "", //$NON-NLS-1$
                this.getCatalog(), this.getId(), -1, -1, System
                    .currentTimeMillis(), 0, null,
                this.pointOfOrigin, message));
          }

          long connectionLifeTime = System.currentTimeMillis()
              - this.connectionCreationTimeMillis;

          if (connectionLifeTime < 500) {
            String message = "Connection lifetime of < .5 seconds. You might be un-necessarily creating short-lived connections and should investigate connection pooling to be more efficient.";

            this.eventSink.consumeEvent(new ProfilerEvent(
                ProfilerEvent.TYPE_WARN, "", //$NON-NLS-1$
                this.getCatalog(), this.getId(), -1, -1, System
                    .currentTimeMillis(), 0, null,
                this.pointOfOrigin, message));
          }
View Full Code Here

  protected void realClose(boolean calledExplicitly) throws SQLException {
    if (this.useUsageAdvisor) {
      if (this.numberOfExecutions <= 1) {
        String message = Messages.getString("PreparedStatement.43"); //$NON-NLS-1$

        this.eventSink.consumeEvent(new ProfilerEvent(
            ProfilerEvent.TYPE_WARN, "", this.currentCatalog, //$NON-NLS-1$
            this.connection.getId(), this.getId(), -1, System
                .currentTimeMillis(), 0, null,
            this.pointOfOrigin, message));
      }
View Full Code Here

TOP

Related Classes of com.mysql.jdbc.profiler.ProfilerEvent

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.