Example usage for java.sql Connection toString

List of usage examples for java.sql Connection toString

Introduction

In this page you can find the example usage for java.sql Connection toString.

Prototype

public String toString() 

Source Link

Document

Returns a string representation of the object.

Usage

From source file:org.talend.core.model.metadata.builder.database.manager.dbs.OracleExtractManager.java

@Override
protected List<String> retrieveItemTables(IMetadataConnection metadataConnection,
        TableInfoParameters tableInfoParameters, List<String> itemTablesName)
        throws SQLException, ClassNotFoundException, InstantiationException, IllegalAccessException {
    ExtractMetaDataUtils extractMeta = ExtractMetaDataUtils.getInstance();
    Connection con = extractMeta.getConn();
    // if want to get all tables and synonyms,need to get the value of the public_synonym_checken botton
    if (con != null && con.toString().contains("oracle.jdbc.driver") //$NON-NLS-1$
            && extractMeta.isUseAllSynonyms()) {
        Set<String> nameFiters = tableInfoParameters.getNameFilters();
        Statement stmt = con.createStatement();
        extractMeta.setQueryStatementTimeout(stmt);

        StringBuffer filters = new StringBuffer();
        if (!nameFiters.isEmpty()) {
            filters.append(" and ("); //$NON-NLS-1$
            final String tStr = " all_synonyms.synonym_name like '"; //$NON-NLS-1$
            int i = 0;
            for (String s : nameFiters) {
                if (i != 0) {
                    filters.append(" or "); //$NON-NLS-1$
                }// www.j  a v  a  2 s  .  co m
                filters.append(tStr);
                filters.append(s);
                filters.append('\'');
                i++;

            }
            filters.append(')');
        }
        ResultSet rsTables = stmt.executeQuery(GET_ALL_SYNONYMS + filters.toString());
        itemTablesName = ExtractMetaDataFromDataBase.getTableNamesFromQuery(rsTables, extractMeta.getConn());
        rsTables.close();
        stmt.close();

        // tableTypeMap.clear();
        for (String synonymName : itemTablesName) {
            getTableTypeMap().put(synonymName, ETableTypes.TABLETYPE_SYNONYM.getName());
        }

    } else {
        itemTablesName = super.retrieveItemTables(metadataConnection, tableInfoParameters, itemTablesName);
    }
    return itemTablesName;
}