/** * Return a concatened and human readable format of provided result set * @param rs result set to read * @param maxFieldLength Maximum field length to print * @param maxPrintedRows Maximum printed rows * @param addColumns Add column header * @param alignColumns Align columns by using padding * @return human readable format of provided result set * @throws SQLException */ public static String resultSetToString(ResultSet rs,int maxFieldLength, int maxPrintedRows, boolean addColumns, boolean alignColumns) throws SQLException { return resultSetToString(rs, maxFieldLength, maxPrintedRows, addColumns, alignColumns, new AcceptAllFilter()); }
@Override public void run(ProgressMonitor pm) { Envelope selectionEnvelope = null; try { selectionEnvelope = ReadTable.getTableSelectionEnvelope(dataManager, tableName, modelSelection, pm); if(selectionEnvelope!=null) { mapContext.setBoundingBox(selectionEnvelope); } }catch (SQLException ex) { LOGGER.error(I18N.tr("Unable to establish the selection bounding box"),ex); } }
stats = ReadTable.computeStatsLocal(connection, table, fieldName, sortedSet, pm); stats = ReadTable.computeStatsSQL(connection, table, fieldName, pm);
@Override public void run(ProgressMonitor pm) { if (model.getRowCount() < 2) { return; } // Retrieve the index if the model have a restricted set of rows if (modelIndex == null) { //Create an array [0 1 ..rows] modelIndex = new IntegerUnion(0, model.getRowCount() - 1); } try(Connection connection = dataSource.getConnection()) { final Collection<Integer> sortedRow = ReadTable.getSortedColumnRowIndex(connection, model.getTableName(), columnSortName, sortRequest.getSortOrder() == SortOrder.ASCENDING, pm); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { try { //Update the table model on the swing thread eventSortedListeners.callListeners(new SortJobEventSorted(sortRequest, sortedRow, this)); } catch (EventException ex) { //Ignore } } }); } catch (IllegalStateException | SQLException ex) { LOGGER.error(I18N.tr("Driver error"), ex); } }
@Override protected Set<Long> doInBackground() throws Exception { Set<Long> newSelection; // Get all primary value where default geometry intersects a bounding box try (Connection connection = SFSUtilities.wrapConnection(activeLayer.getDataManager().getDataSource().getConnection())) { String geomFieldName = SFSUtilities.getGeometryFields(connection, TableLocation.parse(activeLayer.getTableReference())).get(0); newSelection = ReadTable.getTablePkByEnvelope(mc.getDataManager(), activeLayer.getTableReference(), geomFieldName, selectionRect, !intersects); } catch (SQLException e) { automaton.transition(Code.NO_SELECTION); throw new TransitionException(e); } return newSelection; }
/** * Return a concatened and human readable format of provided result set * @param rs result set to read * @param maxFieldLength Maximum field length to print * @param maxPrintedRows Maximum printed rows * @param addColumns Add column header * @param alignColumns Align columns by using padding * @return human readable format of provided result set * @throws SQLException */ public static String resultSetToString(ResultSet rs,int maxFieldLength, int maxPrintedRows, boolean addColumns, boolean alignColumns) throws SQLException { return resultSetToString(rs, maxFieldLength, maxPrintedRows, addColumns, alignColumns, new AcceptAllFilter()); }
/** * Compute the envelope based on the selection * @param pm * @param data * @param tableReference * @return * @throws SQLException */ private Envelope getLayerSelectionEnvelope(ProgressMonitor pm, Set<Long> data,String tableReference) throws SQLException { SortedSet<Long> sortedSet; if(data instanceof SortedSet) { sortedSet = (SortedSet<Long>)data; } else { sortedSet = new LongUnion(data); } return ReadTable.getTableSelectionEnvelope(mapContext.getDataManager(), tableReference,sortedSet, pm); }
pst.setObject(1, envGeom); try(ResultSet rs = pst.executeQuery()) { String lines = ReadTable.resultSetToString(rs, MAX_FIELD_LENGTH, MAX_PRINTED_ROWS, false, false, new EnvelopeFilter(envelope)); UILOGGER.info(lines);
if(isExecuteQuery(lowerCaseQuery)) { try(ResultSet rs = st.executeQuery(query)) { LOGGER.info("\n" + ReadTable.resultSetToString(rs, MAX_FIELD_LENGTH, MAX_PRINTED_ROWS, true, true)); } catch (SQLException ex) {