Checks whether the AbstractIndex classes have output available and
forward them to the output writer.

@throws IOException
if an error occurred while writing the output
@throws SQLException
if an error occurred while accessing the database
428201
private void send()
		throws IOException, SQLException
	{

		this.indexWriter.write(articleIndex);
		this.indexWriter.write(revisionIndex);
		this.indexWriter.write(chronoIndex);
	}
75288
@Override
    public void writeExternal(ObjectOutput output) throws IOException {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) {
            Tr.event(tc, "Serializing: " + this);
        }
        super.writeExternal(output);
        output.writeShort(getStatusCodeAsInt());
        writeByteArray(output, this.myReasonBytes);
    }
675934
@Override
	final public void run() {
		try {
			if(args.length>0) handleCommand(args);
			else runImpl();
			status="Done";
		} catch(IOException exception) {
			this.err.println(getName()+": "+exception.getMessage());
			status="IO Error: "+exception.getMessage();
			this.err.flush();
		} catch(SQLException exception) {
			this.err.println(getName()+": "+exception.getMessage());
			status="SQL Error: "+exception.getMessage();
			this.err.flush();
		} catch(ThreadDeath TD) {
			throw TD;
		} catch(Throwable T) {
			ErrorPrinter.printStackTraces(T, this.err);
			status="Error: "+T.toString();
			this.err.flush();
		} finally {
			if(Thread.currentThread()==thread) thread=null;
		}
	}
1159962
@Override
    public void write(Iterable<QueryResult> results) {
        for (QueryResult result : results) {
            try {
                out.write(result.toString());
            } catch (IOException e) {
                // never occurs
            }
        }
    }
775064
@Override
    public boolean execute() throws SQLException {
        boolean isOk = false;

        try {
            boolean result = internalStmt.execute();
            isOk = true;

            return result;
        } finally {
            poolableConn.updateLastSQLExecutionTime(isOk);
        }
    }
996378
public void write(DataOutput dataOutput) throws IOException {
        dataOutput.writeBoolean(isMaster);
        dataOutput.writeUTF(serverState);
        dataOutput.writeInt(totalUpdates);
        dataOutput.writeInt(streamId);

    }
1225623
public boolean isConnectionError(SQLException ex) {
        final boolean isTraceOn = TraceComponent.isAnyTracingEnabled();

        if (isTraceOn && tc.isEntryEnabled())
            Tr.entry(this, tc, "isConnectionError", ex);

        // Maintain a set in order to check for cycles
        Set<Throwable> chain = new HashSet<Throwable>();

        boolean stale = false;
        for (Throwable t = ex; t != null && !stale && chain.add(t); t = t.getCause()) {
            SQLException sqlX = t instanceof SQLException ? (SQLException) t : null;
            if (isTraceOn && tc.isDebugEnabled())
                Tr.debug(this, tc, "checking " + t,
                         sqlX == null ? null : sqlX.getSQLState(),
                         sqlX == null ? null : sqlX.getErrorCode());
            if (sqlX != null)
                stale |= sqlX instanceof SQLRecoverableException ||
                         sqlX instanceof SQLNonTransientConnectionException ||
                         sqlX instanceof SQLTransientConnectionException && failoverOccurred(sqlX) ||
                         staleErrorCodes.contains(sqlX.getErrorCode()) ||
                         staleSQLStates.contains(sqlX.getSQLState());
        }

        if (isTraceOn && tc.isEntryEnabled())
            Tr.exit(this, tc, "isConnectionError", stale);

        return stale;
    }
65217
public boolean isWrapperFor(Class<?> interfaceClass) throws SQLException {
        TraceComponent tc = getTracer();
        if (tc.isEntryEnabled())
            Tr.entry(this, tc, "isWrapperFor", interfaceClass);

        boolean isWrapper;
        try {
            activate();
            isWrapper = interfaceClass.isInterface()
                        && (interfaceClass.isInstance(this)
                        || ((mcf.jdbcDriverSpecVersion >= 40 && !(this instanceof CommonDataSource)) ?
                                        ((Wrapper) WSJdbcTracer.getImpl(getJDBCImplObject())).isWrapperFor(interfaceClass) :
                                        getJDBCImplObject(interfaceClass) != null));
        } catch (SQLException sqlX) {
            FFDCFilter.processException(
                                        sqlX, getClass().getName() + ".isWrapperFor", "296", this);
            if (tc.isEntryEnabled())
                Tr.exit(this, tc, "isWrapperFor", sqlX);
            throw WSJdbcUtil.mapException(this, sqlX);
        } catch (NullPointerException nullX) {
            // No FFDC code needed; we might be closed.
            throw runtimeXIfNotClosed(nullX);
        } catch (RuntimeException runX) {
            FFDCFilter.processException(
                                        runX, getClass().getName() + ".isWrapperFor", "307", this);
            if (tc.isEntryEnabled())
                Tr.exit(this, tc, "isWrapperFor", runX);
            throw runX;
        } catch (Error err) {
            FFDCFilter.processException(
                                        err, getClass().getName() + ".isWrapperFor", "314", this);
            if (tc.isEntryEnabled())
                Tr.exit(this, tc, "isWrapperFor", err);
            throw err;
        }

        if (tc.isEntryEnabled())
            Tr.exit(this, tc, "isWrapperFor", isWrapper ? Boolean.TRUE : Boolean.FALSE);
        return isWrapper;
    }
436348
@Override
	public ResultSet doQuery(final SqlContext sqlContext, final PreparedStatement preparedStatement,
			final ResultSet resultSet) {
		try {
			if (resultSet.getType() == ResultSet.TYPE_FORWARD_ONLY) {
				LOG.warn("ResultSet type is TYPE_FORWARD_ONLY. DumpResultSqlFilter use ResultSet#beforeFirst(). Please Set TYPE_SCROLL_INSENSITIVE or TYPE_SCROLL_SENSITIVE.");
			}
			StringBuilder builder = displayResult(resultSet);
			LOG.info(builder.toString());
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return resultSet;
	}
1149846
public boolean next() throws SQLException {
        boolean result = queryResult.next();
        orderValues = result ? getOrderValues() : Collections.<Comparable<?>>emptyList();
        return result;
    }
204355
@Local
    @Override
    public int[] directExecute(String... sqls) {
        if (sqls.length == 0) return new int[0];
        Connection conn = writePool.poll();
        try {
            conn.setReadOnly(false);
            final Statement stmt = conn.createStatement();
            final int[] rs = new int[sqls.length];
            int i = -1;
            for (String sql : sqls) {
                rs[++i] = stmt.execute(sql) ? 1 : 0;
            }
            stmt.close();
            return rs;
        } catch (SQLException e) {
            throw new RuntimeException(e);
        } finally {
            if (conn != null) writePool.offerConnection(conn);
        }
    }
820122
@Override
    public void write(DataOutput out) throws IOException {
        if (record != null) record.write(out);
    }
441099
private boolean isSQLErrorTransient(SQLException sqlex) {
        if (tc.isEntryEnabled())
            Tr.entry(tc, "isSQLErrorTransient ", new Object[] { sqlex, this });
        boolean retryBatch = false;
        int sqlErrorCode = sqlex.getErrorCode();

        if (tc.isEventEnabled()) {
            Tr.event(tc, " SQL exception:");
            Tr.event(tc, " Message: " + sqlex.getMessage());
            Tr.event(tc, " SQLSTATE: " + sqlex.getSQLState());
            Tr.event(tc, " Error code: " + sqlErrorCode);
        }

        for (int transientCode : _sqlTransientErrorCodes) {
            Tr.event(tc, "Test against stored code: " + transientCode);
            if (transientCode == sqlErrorCode) {
                Tr.event(tc, "TRANSIENT: A connection failed but could be reestablished, retry.");
                retryBatch = true;
                break;
            }
        }

        if (!retryBatch && sqlex instanceof BatchUpdateException) {
            BatchUpdateException buex = (BatchUpdateException) sqlex;
            Tr.event(tc, "BatchUpdateException: Update Counts - ");
            int[] updateCounts = buex.getUpdateCounts();
            for (int i = 0; i < updateCounts.length; i++) {
                Tr.event(tc, "   Statement " + i + ":" + updateCounts[i]);
            }
            SQLException nextex = buex.getNextException();
            while (nextex != null) {
                sqlErrorCode = nextex.getErrorCode();
                if (tc.isEventEnabled()) {
                    Tr.event(tc, " SQL exception:");
                    Tr.event(tc, " Message: " + nextex.getMessage());
                    Tr.event(tc, " SQLSTATE: " + nextex.getSQLState());

                    Tr.event(tc, " Error code: " + sqlErrorCode);
                }

                for (int transientCode : _sqlTransientErrorCodes) {
                    Tr.event(tc, "Test against stored code: " + transientCode);
                    if (transientCode == sqlErrorCode) {
                        Tr.event(tc, "TRANSIENT: A connection failed but could be reestablished, retry.");
                        retryBatch = true;
                        break;
                    }
                }

                nextex = nextex.getNextException();
            }
        }

        if (tc.isEntryEnabled())
            Tr.exit(tc, "isSQLErrorTransient", retryBatch);
        return retryBatch;
    }
313809
public boolean isConnectionError(SQLException ex) {
        final boolean isTraceOn = TraceComponent.isAnyTracingEnabled();

        if (isTraceOn && tc.isEntryEnabled())
            Tr.entry(this, tc, "isConnectionError", ex);

        // Maintain a set in order to check for cycles
        Set<Throwable> chain = new HashSet<Throwable>();

        boolean stale = super.isConnectionError(ex);
        for (Throwable t = ex; t != null && !stale && chain.add(t); t = t.getCause()) {
            SQLException sqlX = t instanceof SQLException ? (SQLException) t : null;
            if (isTraceOn && tc.isDebugEnabled())
                Tr.debug(this, tc, "checking " + t,
                         sqlX == null ? null : sqlX.getSQLState(),
                         sqlX == null ? null : sqlX.getErrorCode());
            if (sqlX != null)
                stale |= isDataDirectExp(ex)
                         ? staleDDErrorCodes.contains(sqlX.getErrorCode()) || staleDDSQLStates.contains(sqlX.getSQLState())
                         : staleMSErrorCodes.contains(sqlX.getErrorCode());
        }

        if (isTraceOn && tc.isEntryEnabled())
            Tr.exit(this, tc, "isConnectionError", stale);

        return stale;
    }
709386
public void close() throws SQLException {
    if (!closed) {
      // flush any open output streams
      if (os != null) {
        try {
          // we can't call os.close() otherwise we go into an infinite loop!
          os.flush();
        } catch (IOException ioe) {
          throw new PSQLException("Exception flushing output stream", PSQLState.DATA_ERROR, ioe);
        } finally {
          os = null;
        }
      }

      // finally close
      FastpathArg[] args = new FastpathArg[1];
      args[0] = new FastpathArg(fd);
      fp.fastpath("lo_close", args); // true here as we dont care!!
      closed = true;
      if (this.commitOnClose) {
        this.conn.commit();
      }
    }
  }
194864
protected void flushIfPossible() throws IOException {

        // TODO: do not flush if wasn't requested by underlying application
        if (null != bufferedServletOutputStream) bufferedServletOutputStream.setLastChunk();

        if (null != writer) writer.flushIfOpen();
        else if (null != outputStream) outputStream.flushIfOpen();
        else {
            if (!isCommitted()) {
                notifyBeforeCommit();
            }
            notifyBeforeClose();
        }
    }
685841
@Override
  public void clear() throws IOException {
    DBUtils.runInsert(connectionFactory, CLEAR_SQL, DBUtils.EMPTY_SQL_PARAMS,
        sqlNumRetries);
    LOG.info("Clear all values");
  }