@Override public boolean execute() throws SQLException { return execute(false); }
/** * Execute the current batch of statements. If any exception occurs * during execution, a {@link org.apache.phoenix.exception.BatchUpdateException} * is thrown which includes the index of the statement within the * batch when the exception occurred. */ @Override public int[] executeBatch() throws SQLException { int i = 0; try { int[] returnCodes = new int [batch.size()]; for (i = 0; i < returnCodes.length; i++) { PhoenixPreparedStatement statement = batch.get(i); returnCodes[i] = statement.execute(true) ? Statement.SUCCESS_NO_INFO : statement.getUpdateCount(); } // Flush all changes in batch if auto flush is true flushIfNecessary(); // If we make it all the way through, clear the batch clearBatch(); return returnCodes; } catch (Throwable t) { throw new BatchUpdateExecution(t,i); } }
boolean isQuery = stmt.execute(); if (isQuery) { ResultSet rs = stmt.getResultSet();
public static List<KeyRange> getSplits(Connection conn, String tableName, String pkCol, byte[] lowerRange, byte[] upperRange, String whereClauseSuffix, String selectClause) throws SQLException { String whereClauseStart = (lowerRange == null && upperRange == null ? "" : " WHERE " + ((lowerRange != null ? (pkCol + " >= ? " + (upperRange != null ? " AND " : "")) : "") + (upperRange != null ? (pkCol + " < ?") : "" ))); String whereClause = whereClauseSuffix == null ? whereClauseStart : whereClauseStart.length() == 0 ? (" WHERE " + whereClauseSuffix) : (" AND " + whereClauseSuffix); String query = "SELECT /*+ NO_INDEX */ "+selectClause+" FROM " + tableName + whereClause; PhoenixPreparedStatement pstmt = conn.prepareStatement(query).unwrap(PhoenixPreparedStatement.class); if (lowerRange != null) { pstmt.setBytes(1, lowerRange); } if (upperRange != null) { pstmt.setBytes(lowerRange != null ? 2 : 1, upperRange); } pstmt.execute(); List<KeyRange> keyRanges = pstmt.getQueryPlan().getSplits(); return keyRanges; }
@Override public boolean execute() throws SQLException { return execute(false); }
@Override public boolean execute() throws SQLException { return execute(false); }
public static Collection<GuidePostsInfo> getGuidePostsList(Connection conn, String tableName, String pkCol, byte[] lowerRange, byte[] upperRange, String whereClauseSuffix) throws SQLException { String whereClauseStart = (lowerRange == null && upperRange == null ? "" : " WHERE " + ((lowerRange != null ? (pkCol + " >= ? " + (upperRange != null ? " AND " : "")) : "") + (upperRange != null ? (pkCol + " < ?") : ""))); String whereClause = whereClauseSuffix == null ? whereClauseStart : whereClauseStart.length() == 0 ? (" WHERE " + whereClauseSuffix) : (" AND " + whereClauseSuffix); String query = "SELECT /*+ NO_INDEX */ COUNT(*) FROM " + tableName + whereClause; PhoenixPreparedStatement pstmt = conn.prepareStatement(query).unwrap(PhoenixPreparedStatement.class); if (lowerRange != null) { pstmt.setBytes(1, lowerRange); } if (upperRange != null) { pstmt.setBytes(lowerRange != null ? 2 : 1, upperRange); } pstmt.execute(); TableRef tableRef = pstmt.getQueryPlan().getTableRef(); PhoenixConnection pconn = conn.unwrap(PhoenixConnection.class); PTable table = tableRef.getTable(); GuidePostsInfo info = pconn.getQueryServices().getTableStats(new GuidePostsKey(table.getName().getBytes(), SchemaUtil.getEmptyColumnFamily(table))); return Collections.singletonList(info); }
/** * Execute the current batch of statements. If any exception occurs * during execution, a {@link org.apache.phoenix.exception.BatchUpdateException} * is thrown which includes the index of the statement within the * batch when the exception occurred. */ @Override public int[] executeBatch() throws SQLException { int i = 0; try { int[] returnCodes = new int [batch.size()]; for (i = 0; i < returnCodes.length; i++) { PhoenixPreparedStatement statement = batch.get(i); returnCodes[i] = statement.execute(true) ? Statement.SUCCESS_NO_INFO : statement.getUpdateCount(); } // Flush all changes in batch if auto flush is true flushIfNecessary(); // If we make it all the way through, clear the batch clearBatch(); return returnCodes; } catch (Throwable t) { throw new BatchUpdateExecution(t,i); } }
/** * Execute the current batch of statements. If any exception occurs * during execution, a {@link org.apache.phoenix.exception.BatchUpdateException} * is thrown which includes the index of the statement within the * batch when the exception occurred. */ @Override public int[] executeBatch() throws SQLException { int i = 0; try { int[] returnCodes = new int [batch.size()]; for (i = 0; i < returnCodes.length; i++) { PhoenixPreparedStatement statement = batch.get(i); returnCodes[i] = statement.execute(true) ? Statement.SUCCESS_NO_INFO : statement.getUpdateCount(); } // Flush all changes in batch if auto flush is true flushIfNecessary(); // If we make it all the way through, clear the batch clearBatch(); return returnCodes; } catch (Throwable t) { throw new BatchUpdateExecution(t,i); } }
boolean isQuery = stmt.execute(); if (isQuery) { ResultSet rs = stmt.getResultSet();
boolean isQuery = stmt.execute(); if (isQuery) { ResultSet rs = stmt.getResultSet();