code: public static DbaseFileHeader dBaseHeaderFromMetaData(ResultSetMetaData metaData, List<Integer> retainedColumns) throws SQLException {
          DbaseFileHeader dbaseFileHeader = new DbaseFileHeader();
          for(int fieldId= 1; fieldId <= metaData.getColumnCount(); fieldId++) {
              final String fieldTypeName = metaData.getColumnTypeName(fieldId);
              // TODO postgis check field type
              if(!fieldTypeName.equalsIgnoreCase("geometry")) {
                  DBFType dbfType = getDBFType(metaData.getColumnType(fieldId), fieldTypeName, metaData.getColumnDisplaySize(fieldId), metaData.getPrecision(fieldId));
                  try {
                      dbaseFileHeader.addColumn(metaData.getColumnName(fieldId),dbfType.type, dbfType.fieldLength, dbfType.decimalCount);
                      retainedColumns.add(fieldId);
                  } catch (DbaseFileException ex) {
                      throw new SQLException(ex.getLocalizedMessage(), ex);
                  }
              }
          }
          return dbaseFileHeader;
      }
docs: Create a DBF header from the columns specified in parameter.
  @param metaData SQL ResultSetMetadata
  @param retainedColumns list of column indexes
  @return DbfaseFileHeader instance.
  @throws SQLException If one or more type are not supported by DBF