in src/main/java/org/apache/ddlutils/task/DumpMetadataTask.java [219:278]
public void execute() throws BuildException
{
if (_dataSource == null)
{
log("No data source specified, so there is nothing to do.", Project.MSG_INFO);
return;
}
Connection connection = null;
OutputStream output = null;
try
{
connection = _dataSource.getConnection();
if (_outputFile == null)
{
output = System.out;
}
else
{
output = new FileOutputStream(_outputFile);
}
PrettyPrintingXmlWriter xmlWriter = new PrettyPrintingXmlWriter(output, _outputEncoding);
xmlWriter.writeDocumentStart();
xmlWriter.writeElementStart(null, "metadata");
xmlWriter.writeAttribute(null, "driverClassName", _dataSource.getDriverClassName());
dumpMetaData(xmlWriter, connection.getMetaData());
xmlWriter.writeDocumentEnd();
}
catch (Exception ex)
{
throw new BuildException(ex);
}
finally
{
if (connection != null)
{
try
{
connection.close();
}
catch (SQLException ex)
{}
}
if ((_outputFile != null) && (output != null))
{
try
{
output.close();
}
catch (IOException ex)
{}
}
}
}