XMLWriter writer = null;
OutputFormat outputFormat = OutputFormat.createPrettyPrint(); XMLWriter    xmlWriter    = null;
    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;        try        {            Document document = DocumentFactory.getInstance().createDocument();            Element  root     = document.addElement("metadata");            root.addAttribute("driverClassName", _dataSource.getDriverClassName());                        connection = _dataSource.getConnection();                        dumpMetaData(root, connection.getMetaData());            XMLWriter writer = null;            if (_outputFile == null)            {                writer = new XMLWriter(System.out, OutputFormat.createPrettyPrint());            }            else            {                writer = new XMLWriter(new FileWriter(_outputFile), OutputFormat.createPrettyPrint());            }            writer.write(document);            writer.close();        }        catch (Exception ex)        {            throw new BuildException(ex);        }        finally        {            if (connection != null)            {                try                {                    connection.close();                }                catch (SQLException ex)                {}            }        }    }