Search in sources :

Example 16 with DfJdbcFacade

use of org.dbflute.helper.jdbc.facade.DfJdbcFacade in project dbflute-core by dbflute.

the class DfDBLinkNativeExtractorOracle method doSelectDBLinkInfoMap.

protected Map<String, DBLinkNativeInfo> doSelectDBLinkInfoMap(String sql) {
    final DfJdbcFacade facade = new DfJdbcFacade(_dataSource);
    final List<String> columnList = new ArrayList<String>();
    columnList.add("DB_LINK");
    columnList.add("USERNAME");
    columnList.add("HOST");
    final List<Map<String, String>> resultList;
    try {
        log(sql);
        resultList = facade.selectStringList(sql, columnList);
    } catch (Exception continued) {
        // because it's basically assist info
        log("Failed to select DB link info: " + continued.getMessage());
        return DfCollectionUtil.emptyMap();
    }
    final Map<String, DBLinkNativeInfo> infoMap = DfCollectionUtil.newLinkedHashMap();
    for (Map<String, String> map : resultList) {
        final DBLinkNativeInfo info = new DBLinkNativeInfo();
        info.setDbLink(map.get("DB_LINK"));
        info.setUserName(map.get("USERNAME"));
        info.setHost(map.get("HOST"));
        infoMap.put(info.getDbLink(), info);
    }
    return infoMap;
}
Also used : ArrayList(java.util.ArrayList) Map(java.util.Map) DfJdbcFacade(org.dbflute.helper.jdbc.facade.DfJdbcFacade)

Example 17 with DfJdbcFacade

use of org.dbflute.helper.jdbc.facade.DfJdbcFacade in project dbflute-core by dbflute.

the class DfSynonymNativeExtractorOracle method doSelectSynonymInfoMap.

protected Map<String, SynonymNativeInfo> doSelectSynonymInfoMap(String sql, boolean transaction) {
    final DfJdbcFacade facade = new DfJdbcFacade(_dataSource);
    if (transaction) {
        // reported that five or more DB links are not allowed to connect
        // you can avoid it by committing so it uses transaction
        facade.useTransaction();
    }
    final List<String> columnList = new ArrayList<String>();
    columnList.add("SYNONYM_NAME");
    columnList.add("TABLE_OWNER");
    columnList.add("TABLE_NAME");
    columnList.add("DB_LINK");
    final List<Map<String, String>> resultList;
    try {
        log(sql);
        resultList = facade.selectStringList(sql, columnList);
    } catch (Exception continued) {
        // because it's basically assist info
        log("Failed to select synonym info: " + continued.getMessage());
        return DfCollectionUtil.emptyMap();
    }
    final Map<String, SynonymNativeInfo> infoMap = DfCollectionUtil.newLinkedHashMap();
    for (Map<String, String> map : resultList) {
        final SynonymNativeInfo info = new SynonymNativeInfo();
        info.setSynonymName(map.get("SYNONYM_NAME"));
        info.setTableOwner(map.get("TABLE_OWNER"));
        info.setTableName(map.get("TABLE_NAME"));
        infoMap.put(info.getSynonymName(), info);
    }
    return infoMap;
}
Also used : ArrayList(java.util.ArrayList) Map(java.util.Map) DfJdbcFacade(org.dbflute.helper.jdbc.facade.DfJdbcFacade)

Example 18 with DfJdbcFacade

use of org.dbflute.helper.jdbc.facade.DfJdbcFacade in project dbflute-core by dbflute.

the class DfConventionalTakeAsserter method determineEmptyTable.

protected boolean determineEmptyTable(DfTableMeta tableMeta) {
    final DfJdbcFacade facade = new DfJdbcFacade(_dataSource);
    final int countAll = facade.selectCountAll(tableMeta.getTableSqlName());
    return countAll == 0;
}
Also used : DfJdbcFacade(org.dbflute.helper.jdbc.facade.DfJdbcFacade)

Example 19 with DfJdbcFacade

use of org.dbflute.helper.jdbc.facade.DfJdbcFacade in project dbflute-core by dbflute.

the class DfLReverseDataExtractor method selectData.

protected DfLReverseDataResult selectData(Table table) {
    final String tableSqlName = table.getTableSqlNameDirectUse();
    boolean large = false;
    if (_largeBorder > 0) {
        if (_extractingLimit < 0 || _largeBorder < _extractingLimit) {
            final DfJdbcFacade facade = createJdbcFacade();
            final int countAll = facade.selectCountAll(tableSqlName);
            if (countAll > _largeBorder) {
                // it's large
                large = true;
            }
        }
    } else if (_largeBorder == 0) {
        // means all large mode (all TSV files)
        large = true;
    }
    final List<String> sqlList = DfCollectionUtil.newArrayList();
    buildSelfReferenceExtractingTrySqlList(table).ifPresent(trySqlList -> {
        sqlList.addAll(trySqlList);
    });
    sqlList.add(buildDefaultExtractionSql(table));
    if (large) {
        // also mainly here if e.g. xlsLimit = 0
        return processLargeData(table, sqlList);
    } else {
        // mainly here
        return processNormalData(table, sqlList);
    }
}
Also used : DfJdbcFacade(org.dbflute.helper.jdbc.facade.DfJdbcFacade)

Example 20 with DfJdbcFacade

use of org.dbflute.helper.jdbc.facade.DfJdbcFacade in project dbflute-core by dbflute.

the class DfLReverseDataExtractor method processNormalData.

// ===================================================================================
// Normal Data
// ===========
protected DfLReverseDataResult processNormalData(Table table, List<String> sqlList) {
    final DfJdbcFacade facade = createJdbcFacade();
    final Map<String, ValueType> valueTypeMap = createColumnValueTypeMap(table.getColumnList());
    final DfJFadStringConverter converter = createStringConverter();
    final Integer limit = _extractingLimit;
    final List<Map<String, String>> resultList = facade.selectStringList(sqlList, valueTypeMap, converter, limit);
    return new DfLReverseDataResult(resultList);
}
Also used : DfJFadStringConverter(org.dbflute.helper.jdbc.facade.DfJFadStringConverter) ValueType(org.dbflute.jdbc.ValueType) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) DfJdbcFacade(org.dbflute.helper.jdbc.facade.DfJdbcFacade)

Aggregations

DfJdbcFacade (org.dbflute.helper.jdbc.facade.DfJdbcFacade)23 Map (java.util.Map)13 ArrayList (java.util.ArrayList)12 StringKeyMap (org.dbflute.helper.StringKeyMap)5 DfJFadStringConverter (org.dbflute.helper.jdbc.facade.DfJFadStringConverter)4 ValueType (org.dbflute.jdbc.ValueType)4 LinkedHashMap (java.util.LinkedHashMap)2 DfJFadCursorCallback (org.dbflute.helper.jdbc.facade.DfJFadCursorCallback)2 SQLException (java.sql.SQLException)1 SQLFailureException (org.dbflute.exception.SQLFailureException)1 DfProcedureArgumentInfo (org.dbflute.logic.jdbc.metadata.info.DfProcedureArgumentInfo)1