public void writeHeaders(List<String> headerList) throws SQLException, IOException { super.incrementRowAndLineNo(); // This will allow the correct row/line numbers to be used in any exceptions super.writeRow(headerList); }
/** * {@inheritDoc} */ public void write(final ResultSet resultSet) throws SQLException, IOException { if( resultSet == null ) { throw new NullPointerException("ResultSet cannot be null"); } writeHeaders(resultSet); // increments row and line number writeContents(resultSet); // increments row and line number before writing of each row }
private void writeContents(ResultSet resultSet, CellProcessor[] writeProcessors) throws SQLException, IOException { final int numberOfColumns = resultSet.getMetaData().getColumnCount(); final List<Object> objects = new LinkedList<Object>(); final List<Object> processedColumns = new LinkedList<Object>(); while( resultSet.next() ) { super.incrementRowAndLineNo(); // This will allow the correct row/line numbers to be used in any exceptions // thrown before writing occurs objects.clear(); for( int columnIndex = 1; columnIndex <= numberOfColumns; columnIndex++ ) { objects.add(resultSet.getObject(columnIndex)); } Util.executeCellProcessors(processedColumns, objects, writeProcessors, getLineNumber(), getRowNumber()); super.writeRow(processedColumns); } } }
private void writeContents(ResultSet resultSet) throws SQLException, IOException { final int numberOfColumns = resultSet.getMetaData().getColumnCount(); final List<Object> objects = new LinkedList<Object>(); while( resultSet.next() ) { super.incrementRowAndLineNo(); // This will allow the correct row/line numbers to be used in any exceptions // thrown before writing occurs objects.clear(); for( int columnIndex = 1; columnIndex <= numberOfColumns; columnIndex++ ) { objects.add(resultSet.getObject(columnIndex)); } super.writeRow(objects); } }
/** * {@inheritDoc} */ public void write(ResultSet resultSet, CellProcessor[] writeProcessors) throws SQLException, IOException { if( resultSet == null ) { throw new NullPointerException("ResultSet cannot be null"); } if( writeProcessors == null ) { throw new NullPointerException("CellProcessor[] cannot be null"); } writeHeaders(resultSet); // increments row and line number writeContents(resultSet, writeProcessors); // increments row and line number before writing of each row }
private void writeContents(ResultSet resultSet) throws SQLException, IOException { final int numberOfColumns = resultSet.getMetaData().getColumnCount(); final List<Object> objects = new LinkedList<Object>(); LOGGER.debug("writeContents numberOfColumns : {}", numberOfColumns); while( resultSet.next() ) { super.incrementRowAndLineNo(); // This will allow the correct row/line numbers to be used in any exceptions // thrown before writing occurs objects.clear(); for( int columnIndex = 1; columnIndex <= numberOfColumns; columnIndex++ ) { objects.add(resultSet.getObject(columnIndex)); } super.writeRow(objects); } LOGGER.debug("writeContents write completed"); }
private void writeHeaders(ResultSet resultSet, boolean removeSubQueryTableName) throws SQLException, IOException { super.incrementRowAndLineNo(); // This will allow the correct row/line numbers to be used in any exceptions // thrown before writing occurs final ResultSetMetaData meta = resultSet.getMetaData(); final int numberOfColumns = meta.getColumnCount(); final List<Object> headers = new LinkedList<Object>(); for( int columnIndex = 1; columnIndex <= numberOfColumns; columnIndex++ ) { String columnLabel = meta.getColumnLabel(columnIndex); if(removeSubQueryTableName) { if(columnLabel.indexOf(".") > -1) { headers.add(StringUtils.substringAfterLast(columnLabel, ".")); } else { headers.add(columnLabel); } } else { headers.add(columnLabel); } } super.writeRow(headers); }
private void writeHeaders(ResultSet resultSet, boolean removeSubQueryTableName) throws SQLException, IOException { super.incrementRowAndLineNo(); // This will allow the correct row/line numbers to be used in any exceptions // thrown before writing occurs final ResultSetMetaData meta = resultSet.getMetaData(); final int numberOfColumns = meta.getColumnCount(); final List<Object> headers = new LinkedList<Object>(); for( int columnIndex = 1; columnIndex <= numberOfColumns; columnIndex++ ) { if(removeSubQueryTableName) { String columnName = meta.getColumnName(columnIndex); if(columnName.indexOf(".") > -1) { headers.add(StringUtils.substringAfterLast(columnName, ".")); } else { headers.add(columnName); } } else { headers.add(meta.getColumnName(columnIndex)); } } super.writeRow(headers); }