Package com.impossibl.postgres.protocol

Examples of com.impossibl.postgres.protocol.BindExecCommand


    if (needsNamedPortal()) {
      portalName = connection.getNextPortalName();
    }

    BindExecCommand command = connection.getProtocol().createBindExec(portalName, statementName, parameterTypes, parameterValues, resultFields, Object[].class);

    //Set query timeout
    long queryTimeoutMS = SECONDS.toMillis(queryTimeout);
    command.setQueryTimeout(queryTimeoutMS);

    if (fetchSize != null)
      command.setMaxRows(fetchSize);

    if (maxFieldSize != null)
      command.setMaxFieldLength(maxFieldSize);

    this.warningChain = connection.execute(command, true);

    this.command = command;
    this.resultBatches = new ArrayList<>(command.getResultBatches());

    return hasResults();
  }
View Full Code Here


      int[] counts = new int[batchParameterValues.size()];
      Arrays.fill(counts, SUCCESS_NO_INFO);

      List<Object[]> generatedKeys = new ArrayList<>();

      BindExecCommand command = connection.getProtocol().createBindExec(null, null, parameterTypes, Collections.emptyList(), resultFields, Object[].class);

      List<Type> lastParameterTypes = null;
      List<ResultField> lastResultFields = null;

      for (int c = 0, sz = batchParameterValues.size(); c < sz; ++c) {

        List<Type> parameterTypes = mergeTypes(batchParameterTypes.get(c), lastParameterTypes);

        if (lastParameterTypes == null || !lastParameterTypes.equals(parameterTypes)) {

          PrepareCommand prep = connection.getProtocol().createPrepare(null, sqlText, parameterTypes);

          connection.execute(prep, true);

          parameterTypes = prep.getDescribedParameterTypes();
          lastParameterTypes = parameterTypes;
          lastResultFields = prep.getDescribedResultFields();
        }

        List<Object> parameterValues = batchParameterValues.get(c);

        command.setParameterTypes(parameterTypes);
        command.setParameterValues(parameterValues);

        SQLWarning warnings = connection.execute(command, true);

        warningChain = chainWarnings(warningChain, warnings);

        List<QueryCommand.ResultBatch> resultBatches = command.getResultBatches();
        if (resultBatches.size() != 1) {
          throw new BatchUpdateException(counts);
        }

        QueryCommand.ResultBatch resultBatch = resultBatches.get(0);
View Full Code Here

  }

  private QueryCommand.ResultBatch preparedQuery(String portalName, String statementName, Class<?> rowType, List<Type> paramTypes, List<Object> paramValues,
      List<ResultField> resultFields) throws IOException, NoticeException {

    BindExecCommand query = protocol.createBindExec(portalName, statementName, paramTypes, paramValues, resultFields, rowType);

    protocol.execute(query);

    if (query.getError() != null) {
      throw new NoticeException("Error executing query", query.getError());
    }

    List<QueryCommand.ResultBatch> resultBatches = query.getResultBatches();
    if (resultBatches.isEmpty())
      return null;

    return resultBatches.get(0);
  }
View Full Code Here

TOP

Related Classes of com.impossibl.postgres.protocol.BindExecCommand

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.