Example usage for org.xml.sax.helpers AttributesImpl clear

List of usage examples for org.xml.sax.helpers AttributesImpl clear

Introduction

In this page you can find the example usage for org.xml.sax.helpers AttributesImpl clear.

Prototype

public void clear() 

Source Link

Document

Clear the attribute list for reuse.

Usage

From source file:net.ontopia.persistence.rdbms.DatabaseProjectReader.java

public static void saveProject(Project project, ContentHandler dh) throws SAXException {
    AttributesImpl atts = new AttributesImpl();

    dh.startDocument();//  w  ww.  j av  a 2 s .co  m

    dh.startElement(EMPTY_NAMESPACE, EMPTY_LOCALNAME, "dbschema", EMPTY_ATTR_LIST);

    Iterator<String> platforms = project.getDataTypePlatforms().iterator();
    if (platforms.hasNext()) {
        while (platforms.hasNext()) {
            String platform = platforms.next();

            atts.clear();
            atts.addAttribute(EMPTY_NAMESPACE, EMPTY_LOCALNAME, PLATFORM, CDATA, platform);
            dh.startElement(EMPTY_NAMESPACE, EMPTY_LOCALNAME, "datatypes", atts);

            Iterator<DataType> datatypes = project.getDataTypes(platform).iterator();
            while (datatypes.hasNext()) {
                // Platform datatypes
                DataType datatype = datatypes.next();
                atts.clear();
                atts.addAttribute(EMPTY_NAMESPACE, EMPTY_LOCALNAME, NAME, CDATA, (datatype.getName()));
                atts.addAttribute(EMPTY_NAMESPACE, EMPTY_LOCALNAME, TYPE, CDATA, (datatype.getType()));
                atts.addAttribute(EMPTY_NAMESPACE, EMPTY_LOCALNAME, SIZE, CDATA,
                        (datatype.getSize() == null ? "" : datatype.getSize()));
                atts.addAttribute(EMPTY_NAMESPACE, EMPTY_LOCALNAME, "class", CDATA,
                        (datatype.isVariable() ? "variable" : "constant"));

                dh.startElement(EMPTY_NAMESPACE, EMPTY_LOCALNAME, "datatype", atts);

                // Datatype properties
                Iterator<String> properties = datatype.getProperties().iterator();
                while (properties.hasNext()) {
                    String name = properties.next();
                    String value = datatype.getProperty(name);
                    if (value != null) {
                        atts.clear();
                        atts.addAttribute(EMPTY_NAMESPACE, EMPTY_LOCALNAME, NAME, CDATA, name);
                        atts.addAttribute(EMPTY_NAMESPACE, EMPTY_LOCALNAME, VALUE, CDATA, value);
                        dh.startElement(EMPTY_NAMESPACE, EMPTY_LOCALNAME, PROPERTY, atts);
                        dh.endElement(EMPTY_NAMESPACE, EMPTY_LOCALNAME, PROPERTY);
                    }
                }

                dh.endElement(EMPTY_NAMESPACE, EMPTY_LOCALNAME, "datatype");

            }
        }
        dh.endElement(EMPTY_NAMESPACE, EMPTY_LOCALNAME, "datatypes");
    }

    Iterator<Table> tables = project.getTables().iterator();
    while (tables.hasNext()) {
        Table table = tables.next();

        // Table attributes
        atts.clear();
        atts.addAttribute(EMPTY_NAMESPACE, EMPTY_LOCALNAME, NAME, CDATA, table.getName());
        if (table.getShortName() != null)
            atts.addAttribute(EMPTY_NAMESPACE, EMPTY_LOCALNAME, "short", CDATA, table.getShortName());
        if (table.getPrimaryKeys() != null)
            atts.addAttribute(EMPTY_NAMESPACE, EMPTY_LOCALNAME, "pks", CDATA,
                    StringUtils.join(table.getPrimaryKeys(), " "));
        dh.startElement(EMPTY_NAMESPACE, EMPTY_LOCALNAME, "table", atts);

        // Table properties
        Iterator<String> properties = table.getProperties().iterator();
        while (properties.hasNext()) {
            String name = properties.next();
            String value = table.getProperty(name);
            if (value != null) {
                atts.clear();
                atts.addAttribute(EMPTY_NAMESPACE, EMPTY_LOCALNAME, NAME, CDATA, name);
                atts.addAttribute(EMPTY_NAMESPACE, EMPTY_LOCALNAME, VALUE, CDATA, value);
                dh.startElement(EMPTY_NAMESPACE, EMPTY_LOCALNAME, PROPERTY, atts);
                dh.endElement(EMPTY_NAMESPACE, EMPTY_LOCALNAME, PROPERTY);
            }
        }

        Iterator<Column> columns = table.getColumns().iterator();
        while (columns.hasNext()) {
            Column column = columns.next();

            // Column attributes
            atts.clear();
            atts.addAttribute(EMPTY_NAMESPACE, EMPTY_LOCALNAME, NAME, CDATA, column.getName());
            atts.addAttribute(EMPTY_NAMESPACE, EMPTY_LOCALNAME, TYPE, CDATA, column.getType());

            if (column.isReference()) {
                atts.addAttribute(EMPTY_NAMESPACE, EMPTY_LOCALNAME, "reftab", CDATA,
                        column.getReferencedTable());
                atts.addAttribute(EMPTY_NAMESPACE, EMPTY_LOCALNAME, "refcol", CDATA,
                        column.getReferencedColumn());
            }

            if (column.getSize() != null)
                atts.addAttribute(EMPTY_NAMESPACE, EMPTY_LOCALNAME, SIZE, CDATA, column.getName());
            if (column.isNullable())
                atts.addAttribute(EMPTY_NAMESPACE, EMPTY_LOCALNAME, "null", CDATA, "yes");
            if (column.getDefault() != null)
                atts.addAttribute(EMPTY_NAMESPACE, EMPTY_LOCALNAME, "default", CDATA, column.getDefault());
            dh.startElement(EMPTY_NAMESPACE, EMPTY_LOCALNAME, "column", atts);

            // Column properties
            Iterator<String> properties2 = column.getProperties().iterator();
            while (properties2.hasNext()) {
                String name = properties2.next();
                String value = column.getProperty(name);
                if (value != null) {
                    atts.clear();
                    atts.addAttribute(EMPTY_NAMESPACE, EMPTY_LOCALNAME, NAME, CDATA, name);
                    atts.addAttribute(EMPTY_NAMESPACE, EMPTY_LOCALNAME, VALUE, CDATA, value);
                    dh.startElement(EMPTY_NAMESPACE, EMPTY_LOCALNAME, PROPERTY, atts);
                    dh.endElement(EMPTY_NAMESPACE, EMPTY_LOCALNAME, PROPERTY);
                }
            }
            dh.endElement(EMPTY_NAMESPACE, EMPTY_LOCALNAME, "column");
        }

        dh.endElement(EMPTY_NAMESPACE, EMPTY_LOCALNAME, "table");
    }

    dh.endElement(EMPTY_NAMESPACE, EMPTY_LOCALNAME, "dbschema");
    dh.endDocument();
}

From source file:it.polito.tellmefirst.web.rest.interfaces.EpubInterface.java

private String produceXML(ArrayList<String[]> topics) throws TMFOutputException {
    LOG.debug("[produceXML] - BEGIN");
    String xml;//from w  ww. java2s. c  o m
    try {
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        TransformerHandler hd = initXMLDoc(out);
        AttributesImpl atts = new AttributesImpl();
        atts.addAttribute("", "", "service", "", "ClassifyEpub");
        hd.startElement("", "", "Classification", atts);
        int i = 0;
        for (String[] topic : topics) {
            if (i == 0) {
                atts.clear();
                hd.startElement("", "", "Resources", atts);
            }
            atts.addAttribute("", "", "uri", "", topic[0]);
            atts.addAttribute("", "", "label", "", topic[1]);
            atts.addAttribute("", "", "title", "", topic[2]);
            atts.addAttribute("", "", "score", "", topic[3]);
            atts.addAttribute("", "", "mergedTypes", "", topic[4]);
            atts.addAttribute("", "", "image", "", topic[5]);
            hd.startElement("", "", "Resource", atts);
            hd.endElement("", "", "Resource");
            i++;
        }
        if (i > 0)
            hd.endElement("", "", "Resources");
        hd.endElement("", "", "Classification");
        hd.endDocument();
        xml = out.toString("utf-8");
        System.out.println(xml);
    } catch (Exception e) {
        throw new TMFOutputException("Error creating XML output.", e);
    }
    LOG.debug("[produceXML] - END");
    return xml;
}

From source file:it.polito.tellmefirst.web.rest.interfaces.ClassifyInterface.java

private String produceXML(List<String[]> topics) throws TMFOutputException {
    LOG.debug("[produceXML] - BEGIN");
    String xml;// w ww  .j  a  v a2 s  . c om
    try {
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        TransformerHandler hd = initXMLDoc(out);
        AttributesImpl atts = new AttributesImpl();
        atts.addAttribute("", "", "service", "", "Classify");
        hd.startElement("", "", "Classification", atts);
        int i = 0;
        for (String[] topic : topics) {
            if (i == 0) {
                atts.clear();
                hd.startElement("", "", "Resources", atts);
            }
            atts.addAttribute("", "", "uri", "", topic[0]);
            atts.addAttribute("", "", "label", "", topic[1]);
            atts.addAttribute("", "", "title", "", topic[2]);
            atts.addAttribute("", "", "score", "", topic[3]);
            atts.addAttribute("", "", "mergedTypes", "", topic[4]);
            atts.addAttribute("", "", "image", "", ""); // We should remove this parameter in favour of Wikimedia/Wikidata API
            hd.startElement("", "", "Resource", atts);
            hd.endElement("", "", "Resource");
            i++;
        }
        if (i > 0)
            hd.endElement("", "", "Resources");
        hd.endElement("", "", "Classification");
        hd.endDocument();
        xml = out.toString("utf-8");
        System.out.println(xml);
    } catch (Exception e) {
        throw new TMFOutputException("Error creating XML output.", e);
    }
    LOG.debug("[produceXML] - END");
    return xml;
}

From source file:dicoogle.ua.dim.DIMGeneric.java

public String getXML() {

    StringWriter writer = new StringWriter();

    StreamResult streamResult = new StreamResult(writer);
    SAXTransformerFactory tf = (SAXTransformerFactory) TransformerFactory.newInstance();
    //      SAX2.0 ContentHandler.
    TransformerHandler hd = null;
    try {/* w w w . j a v  a 2s . co m*/
        hd = tf.newTransformerHandler();
    } catch (TransformerConfigurationException ex) {
        Logger.getLogger(DIMGeneric.class.getName()).log(Level.SEVERE, null, ex);
    }
    Transformer serializer = hd.getTransformer();
    serializer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
    serializer.setOutputProperty(OutputKeys.METHOD, "xml");
    serializer.setOutputProperty(OutputKeys.INDENT, "yes");
    serializer.setOutputProperty(OutputKeys.STANDALONE, "yes");
    hd.setResult(streamResult);
    try {
        hd.startDocument();

        AttributesImpl atts = new AttributesImpl();
        hd.startElement("", "", "DIM", atts);

        for (Patient p : this.patients) {
            atts.clear();
            atts.addAttribute("", "", "name", "", p.getPatientName().trim());
            atts.addAttribute("", "", "id", "", p.getPatientID().trim());
            hd.startElement("", "", "Patient", atts);

            for (Study s : p.getStudies()) {
                atts.clear();
                atts.addAttribute("", "", "date", "", s.getStudyData().trim());
                atts.addAttribute("", "", "id", "", s.getStudyInstanceUID().trim());

                hd.startElement("", "", "Study", atts);

                for (Serie serie : s.getSeries()) {
                    atts.clear();
                    atts.addAttribute("", "", "modality", "", serie.getModality().trim());
                    atts.addAttribute("", "", "id", "", serie.getSerieInstanceUID().trim());

                    hd.startElement("", "", "Serie", atts);

                    ArrayList<URI> img = serie.getImageList();
                    ArrayList<String> uid = serie.getSOPInstanceUIDList();
                    int size = img.size();
                    for (int i = 0; i < size; i++) {
                        atts.clear();
                        atts.addAttribute("", "", "path", "", img.get(i).toString().trim());
                        atts.addAttribute("", "", "uid", "", uid.get(i).trim());

                        hd.startElement("", "", "Image", atts);
                        hd.endElement("", "", "Image");
                    }
                    hd.endElement("", "", "Serie");
                }
                hd.endElement("", "", "Study");
            }
            hd.endElement("", "", "Patient");
        }
        hd.endElement("", "", "DIM");

    } catch (SAXException ex) {
        Logger.getLogger(DIMGeneric.class.getName()).log(Level.SEVERE, null, ex);
    }

    return writer.toString();
}

From source file:org.syncope.core.report.UserReportlet.java

private void doExtract(final ContentHandler handler, final UserReportletConf conf,
        final List<SyncopeUser> users) throws SAXException, ReportException {

    AttributesImpl atts = new AttributesImpl();
    for (SyncopeUser user : users) {
        atts.clear();

        for (Feature feature : conf.getFeatures()) {
            String type = null;//from   w  w w.j a v  a 2  s  . co  m
            String value = null;
            switch (feature) {
            case id:
                type = XSD_LONG;
                value = String.valueOf(user.getId());
                break;

            case username:
                type = XSD_STRING;
                value = user.getUsername();
                break;

            case workflowId:
                type = XSD_LONG;
                value = String.valueOf(user.getWorkflowId());
                break;

            case status:
                type = XSD_STRING;
                value = user.getStatus();
                break;

            case creationDate:
                type = XSD_DATETIME;
                value = user.getCreationDate() == null ? "" : DATE_FORMAT.get().format(user.getCreationDate());
                break;

            case lastLoginDate:
                type = XSD_DATETIME;
                value = user.getLastLoginDate() == null ? ""
                        : DATE_FORMAT.get().format(user.getLastLoginDate());
                break;

            case changePwdDate:
                type = XSD_DATETIME;
                value = user.getChangePwdDate() == null ? ""
                        : DATE_FORMAT.get().format(user.getChangePwdDate());
                break;

            case passwordHistorySize:
                type = XSD_INT;
                value = String.valueOf(user.getPasswordHistory().size());
                break;

            case failedLoginCount:
                type = XSD_INT;
                value = String.valueOf(user.getFailedLogins());
                break;

            default:
            }

            if (type != null && value != null) {
                atts.addAttribute("", "", feature.name(), type, value);
            }
        }

        handler.startElement("", "", "user", atts);

        // Using UserTO for attribute values, since the conversion logic of
        // values to String is already encapsulated there
        UserTO userTO = userDataBinder.getUserTO(user);

        doExtractAttributes(handler, userTO, conf.getAttrs(), conf.getDerAttrs(), conf.getVirAttrs());

        if (conf.getFeatures().contains(Feature.memberships)) {
            handler.startElement("", "", "memberships", null);

            for (MembershipTO memb : userTO.getMemberships()) {
                atts.clear();

                atts.addAttribute("", "", "id", XSD_LONG, String.valueOf(memb.getId()));
                atts.addAttribute("", "", "roleId", XSD_LONG, String.valueOf(memb.getRoleId()));
                atts.addAttribute("", "", "roleName", XSD_STRING, String.valueOf(memb.getRoleName()));
                handler.startElement("", "", "membership", atts);

                doExtractAttributes(handler, memb, memb.getAttributeMap().keySet(),
                        memb.getDerivedAttributeMap().keySet(), memb.getVirtualAttributeMap().keySet());

                if (conf.getFeatures().contains(Feature.resources)) {
                    Membership actualMemb = user.getMembership(memb.getRoleId());
                    if (actualMemb == null) {
                        LOG.warn("Unexpected: cannot find membership for " + "role {} for user {}",
                                memb.getRoleId(), user);
                    } else {
                        doExtractResources(handler, roleDataBinder.getRoleTO(actualMemb.getSyncopeRole()));
                    }
                }

                handler.endElement("", "", "membership");
            }

            handler.endElement("", "", "memberships");
        }

        if (conf.getFeatures().contains(Feature.resources)) {
            doExtractResources(handler, userTO);
        }

        handler.endElement("", "", "user");
    }
}

From source file:org.syncope.core.report.UserReportlet.java

private void doExtractResources(final ContentHandler handler, final AbstractAttributableTO attributableTO)
        throws SAXException {

    if (attributableTO.getResources().isEmpty()) {
        LOG.debug("No resources found for {}[{}]", attributableTO.getClass().getSimpleName(),
                attributableTO.getId());
    } else {//from  w  w w.  j ava  2 s  . c  om
        AttributesImpl atts = new AttributesImpl();
        handler.startElement("", "", "resources", null);

        for (String resourceName : attributableTO.getResources()) {
            atts.clear();

            atts.addAttribute("", "", ATTR_NAME, XSD_STRING, resourceName);
            handler.startElement("", "", "resource", atts);
            handler.endElement("", "", "resource");
        }

        handler.endElement("", "", "resources");
    }
}

From source file:it.polito.tellmefirst.web.rest.interfaces.EpubChaptersInterface.java

private String produceXML(HashMap<String, List<String[]>> chapters) throws TMFOutputException {

    LOG.debug("[produceXML] - BEGIN");

    String xml;//from   ww  w.jav  a  2s  .  co  m
    try {
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        TransformerHandler hd = initXMLDoc(out);
        AttributesImpl atts = new AttributesImpl();
        atts.addAttribute("", "", "service", "", "ClassifyEpubChapters");
        hd.startElement("", "", "Classification", atts);
        int i = 0;
        Set set = chapters.entrySet();
        Iterator iterator = set.iterator();
        while (iterator.hasNext()) {
            Map.Entry me = (Map.Entry) iterator.next();
            atts.clear();
            if (i == 0) {
                hd.startElement("", "", "Chapters", atts);
            }
            atts.addAttribute("", "", "toc", "", me.getKey().toString());
            hd.startElement("", "", "Chapter", atts);
            atts.clear();
            ArrayList<String[]> topics = (ArrayList<String[]>) me.getValue();
            int j = 0;
            for (String[] topic : topics) {
                atts.clear();
                if (j == 0) {
                    hd.startElement("", "", "Resources", atts);
                }
                atts.addAttribute("", "", "uri", "", topic[0]);
                atts.addAttribute("", "", "label", "", topic[1]);
                atts.addAttribute("", "", "title", "", topic[2]);
                atts.addAttribute("", "", "score", "", topic[3]);
                atts.addAttribute("", "", "mergedTypes", "", topic[4]);
                atts.addAttribute("", "", "image", "", topic[5]);
                hd.startElement("", "", "Resource", atts);
                hd.endElement("", "", "Resource");
                j++;
            }
            if (j > 0)
                hd.endElement("", "", "Resources");
            hd.endElement("", "", "Chapter");
            i++;
        }
        if (i > 0)
            hd.endElement("", "", "Chapters");
        hd.endElement("", "", "Classification");
        hd.endDocument();
        xml = out.toString("utf-8");
        System.out.println(xml);
    } catch (Exception e) {
        throw new TMFOutputException("Error creating XML output.", e);
    }

    LOG.debug("[produceXML] - END");

    return xml;
}

From source file:org.syncope.core.report.UserReportlet.java

private void doExtractAttributes(final ContentHandler handler, final AbstractAttributableTO attributableTO,
        final Collection<String> attrs, final Collection<String> derAttrs, final Collection<String> virAttrs)
        throws SAXException {

    AttributesImpl atts = new AttributesImpl();
    if (!attrs.isEmpty()) {
        Map<String, AttributeTO> attrMap = attributableTO.getAttributeMap();

        handler.startElement("", "", "attributes", null);
        for (String attrName : attrs) {
            atts.clear();

            atts.addAttribute("", "", ATTR_NAME, XSD_STRING, attrName);
            handler.startElement("", "", "attribute", atts);

            if (attrMap.containsKey(attrName)) {
                for (String value : attrMap.get(attrName).getValues()) {
                    handler.startElement("", "", "value", null);
                    handler.characters(value.toCharArray(), 0, value.length());
                    handler.endElement("", "", "value");
                }//  w ww . j  a v  a  2 s. c  o  m
            } else {
                LOG.debug("{} not found for {}[{}]", new Object[] { attrName,
                        attributableTO.getClass().getSimpleName(), attributableTO.getId() });
            }

            handler.endElement("", "", "attribute");
        }
        handler.endElement("", "", "attributes");
    }

    if (!derAttrs.isEmpty()) {
        Map<String, AttributeTO> derAttrMap = attributableTO.getDerivedAttributeMap();

        handler.startElement("", "", "derivedAttributes", null);
        for (String attrName : derAttrs) {
            atts.clear();

            atts.addAttribute("", "", ATTR_NAME, XSD_STRING, attrName);
            handler.startElement("", "", "derivedAttribute", atts);

            if (derAttrMap.containsKey(attrName)) {
                for (String value : derAttrMap.get(attrName).getValues()) {
                    handler.startElement("", "", "value", null);
                    handler.characters(value.toCharArray(), 0, value.length());
                    handler.endElement("", "", "value");
                }
            } else {
                LOG.debug("{} not found for {}[{}]", new Object[] { attrName,
                        attributableTO.getClass().getSimpleName(), attributableTO.getId() });
            }

            handler.endElement("", "", "derivedAttribute");
        }
        handler.endElement("", "", "derivedAttributes");
    }

    if (!virAttrs.isEmpty()) {
        Map<String, AttributeTO> virAttrMap = attributableTO.getVirtualAttributeMap();

        handler.startElement("", "", "virtualAttributes", null);
        for (String attrName : virAttrs) {
            atts.clear();

            atts.addAttribute("", "", ATTR_NAME, XSD_STRING, attrName);
            handler.startElement("", "", "virtualAttribute", atts);

            if (virAttrMap.containsKey(attrName)) {
                for (String value : virAttrMap.get(attrName).getValues()) {
                    handler.startElement("", "", "value", null);
                    handler.characters(value.toCharArray(), 0, value.length());
                    handler.endElement("", "", "value");
                }
            } else {
                LOG.debug("{} not found for {}[{}]", new Object[] { attrName,
                        attributableTO.getClass().getSimpleName(), attributableTO.getId() });
            }

            handler.endElement("", "", "virtualAttribute");
        }
        handler.endElement("", "", "virtualAttributes");
    }
}

From source file:hd3gtv.mydmam.db.BackupDbCassandra.java

public void onFoundRow(Row<String, String> row) throws Exception {
    AttributesImpl atts = new AttributesImpl();

    atts.addAttribute("", "", "name", "CDATA", row.getKey());
    content.startElement("", "", "key", atts);

    columnlist = row.getColumns();//from w w w  .j  a  v  a2s.c  o m
    String columnvalue = null;
    for (int poscol = 0; poscol < columnlist.size(); poscol++) {
        column = columnlist.getColumnByIndex(poscol);
        atts.clear();
        atts.addAttribute("", "", "name", "CDATA", column.getName());
        atts.addAttribute("", "", "at", "CDATA", String.valueOf(column.getTimestamp() / 1000));
        atts.addAttribute("", "", "ttl", "CDATA", String.valueOf(column.getTtl()));

        columnvalue = new String(quotedprintablecodec.encode(column.getByteArrayValue()));

        if (BackupDb.mode_debug) {
            atts.addAttribute("", "", "at_date", "CDATA", (new Date(column.getTimestamp() / 1000)).toString());
            if (column.getStringValue().equals(columnvalue) == false) {
                atts.addAttribute("", "", "hex_value", "CDATA",
                        MyDMAM.byteToString(column.getByteArrayValue()));
            }
        }

        content.startElement("", "", "col", atts);
        content.characters(columnvalue.toCharArray(), 0, columnvalue.length());
        content.endElement("", "", column.getName());
    }

    content.endElement("", "", "key");
    count++;
}

From source file:org.syncope.core.util.ImportExport.java

private void doExportTable(final TransformerHandler handler, final Connection conn, final String tableName)
        throws SQLException, SAXException {

    AttributesImpl atts = new AttributesImpl();

    PreparedStatement stmt = null;
    ResultSet rs = null;//ww w.ja  va  2  s.  c om
    try {
        stmt = conn.prepareStatement("SELECT * FROM " + tableName + " a");
        rs = stmt.executeQuery();
        for (int rowNo = 0; rs.next(); rowNo++) {
            atts.clear();

            ResultSetMetaData metaData = rs.getMetaData();
            for (int i = 0; i < metaData.getColumnCount(); i++) {
                String columnName = metaData.getColumnName(i + 1);
                String value = rs.getString(columnName);
                if (value != null) {
                    atts.addAttribute("", "", columnName, "CDATA", value);
                }
            }

            handler.startElement("", "", tableName, atts);
            handler.endElement("", "", tableName);
        }
    } finally {
        if (rs != null) {
            try {
                rs.close();
            } catch (SQLException e) {
                LOG.error("While closing result set", e);
            }
        }
        if (stmt != null) {
            try {
                stmt.close();
            } catch (SQLException e) {
                LOG.error("While closing result set", e);
            }
        }
    }
}