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;
}
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;
}
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;
}
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);
}
}
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);
}
Aggregations