Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
========================================================================
SchemaCrawler
http://www.schemacrawler.com
Copyright (c) 2000-2020, Sualeh Fatehi .
All rights reserved.
------------------------------------------------------------------------
SchemaCrawler is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
SchemaCrawler and the accompanying materials are made available under
the terms of the Eclipse Public License v1.0, GNU General Public License
v3 or GNU Lesser General Public License v3.
You may elect to redistribute this code under any of these licenses.
The Eclipse Public License is available at:
http://www.eclipse.org/legal/epl-v10.html
The GNU General Public License v3 and the GNU Lesser General Public
License v3 are available at:
http://www.gnu.org/licenses/
========================================================================
*/
package schemacrawler.crawl;
import static java.sql.Types.BLOB;
import static java.sql.Types.CLOB;
import static java.sql.Types.LONGNVARCHAR;
import static java.sql.Types.LONGVARBINARY;
import static java.sql.Types.LONGVARCHAR;
import static java.sql.Types.NCLOB;
import static java.util.Objects.requireNonNull;
import static schemacrawler.schemacrawler.QueryUtility.executeAgainstSchema;
import static schemacrawler.utility.EnumUtility.enumValue;
import static schemacrawler.utility.EnumUtility.enumValueFromId;
import static us.fatehi.utility.DatabaseUtility.logSQLWarnings;
import static us.fatehi.utility.IOUtility.readFully;
import static us.fatehi.utility.Utility.isBlank;
import static us.fatehi.utility.Utility.isIntegral;
import java.io.Reader;
import java.math.BigInteger;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.logging.Level;
import schemacrawler.SchemaCrawlerLogger;
import schemacrawler.inclusionrule.InclusionRule;
import schemacrawler.schema.IdentifiedEnum;
import schemacrawler.schema.ResultsColumn;
import schemacrawler.schema.ResultsColumns;
import schemacrawler.schemacrawler.Query;
import schemacrawler.utility.BinaryData;
import us.fatehi.utility.string.StringFormat;
/**
* A wrapper around a JDBC resultset obtained from a database metadata call.
* This allows type-safe methods to obtain boolean, integer and string data,
* while abstracting away the quirks of the JDBC metadata API.
*
* @author Sualeh Fatehi
*/
public final class MetadataResultSet
implements AutoCloseable
{
private static final SchemaCrawlerLogger LOGGER =
SchemaCrawlerLogger.getLogger(MetadataResultSet.class.getName());
private static final int FETCHSIZE = 20;
private final ResultsColumns resultsColumns;
private final ResultSet results;
private String description;
private Set readColumns;
private int rowCount;
private boolean showLobs;
public MetadataResultSet(final Query query,
final Statement statement,
final InclusionRule schemaInclusionRule)
throws SQLException
{
this(executeAgainstSchema(query, statement, schemaInclusionRule));
description = query.getName();
}
public MetadataResultSet(final ResultSet resultSet)
throws SQLException
{
results = requireNonNull(resultSet, "Cannot use null results");
try
{
results.setFetchSize(FETCHSIZE);
}
catch (final NullPointerException | SQLException e)
{
LOGGER.log(Level.WARNING, "Could not set fetch size", e);
}
resultsColumns = new ResultsCrawler(results).crawl();
readColumns = new HashSet<>();
showLobs = true;
}
public void setShowLobs(final boolean showLobs)
{
this.showLobs = showLobs;
}
public String[] getColumnNames()
{
final List columnNames = new ArrayList<>();
resultsColumns.forEach(resultsColumn -> columnNames.add(resultsColumn.getName()));
return columnNames.toArray(new String[columnNames.size()]);
}
public List