use of org.dbflute.helper.jdbc.facade.DfJdbcFacade in project dbflute-core by dbflute.
the class DfLReverseDataExtractor method processLargeData.
// ===================================================================================
// Large Data
// ==========
protected DfLReverseDataResult processLargeData(Table table, final List<String> sqlList) {
final DfJdbcFacade facade = createJdbcFacade();
final Map<String, ValueType> valueTypeMap = createColumnValueTypeMap(table.getColumnList());
final DfJFadStringConverter converter = createStringConverter();
final DfJFadCursorCallback callback = facade.selectCursor(sqlList, valueTypeMap, converter);
return new DfLReverseDataResult(callback);
}
use of org.dbflute.helper.jdbc.facade.DfJdbcFacade in project dbflute-core by dbflute.
the class DfProcedureNativeExtractorOracle method doSelectProcedureNativeInfoMap.
protected Map<String, ProcedureNativeInfo> doSelectProcedureNativeInfoMap(String sql) {
final DfJdbcFacade facade = new DfJdbcFacade(_dataSource);
final List<String> columnList = new ArrayList<String>();
columnList.add("OBJECT_NAME");
columnList.add("PROCEDURE_NAME");
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 procedure native info: " + continued.getMessage());
return DfCollectionUtil.emptyMap();
}
final Map<String, ProcedureNativeInfo> infoMap = DfCollectionUtil.newLinkedHashMap();
for (Map<String, String> map : resultList) {
final ProcedureNativeInfo info = new ProcedureNativeInfo();
final String objectName = map.get("OBJECT_NAME");
final String procedureName = map.get("PROCEDURE_NAME");
// translate Oracle's strange data structure
if (Srl.is_NotNull_and_NotTrimmedEmpty(procedureName)) {
// objectName is packageName here
info.setPackageName(objectName);
info.setProcedureName(procedureName);
} else {
// objectName is procedureName here
info.setProcedureName(objectName);
}
infoMap.put(generateNativeInfoMapKey(objectName, procedureName), info);
}
return infoMap;
}
use of org.dbflute.helper.jdbc.facade.DfJdbcFacade in project dbflute-core by dbflute.
the class DfProcedureParameterNativeExtractorOracle method doSelectProcedureArgumentInfoList.
protected List<DfProcedureArgumentInfo> doSelectProcedureArgumentInfoList(String sql) {
final DfJdbcFacade facade = new DfJdbcFacade(_dataSource);
final List<String> columnList = new ArrayList<String>();
columnList.add("PACKAGE_NAME");
columnList.add("OBJECT_NAME");
columnList.add("OVERLOAD");
columnList.add("SEQUENCE");
columnList.add("ARGUMENT_NAME");
columnList.add("IN_OUT");
columnList.add("DATA_TYPE");
columnList.add("DATA_LENGTH");
columnList.add("DATA_PRECISION");
columnList.add("DATA_SCALE");
columnList.add("TYPE_OWNER");
columnList.add("TYPE_NAME");
columnList.add("TYPE_SUBNAME");
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 procedure argument info: " + continued.getMessage());
return DfCollectionUtil.emptyList();
}
final List<DfProcedureArgumentInfo> infoList = DfCollectionUtil.newArrayList();
for (Map<String, String> map : resultList) {
final DfProcedureArgumentInfo info = new DfProcedureArgumentInfo();
info.setPackageName(map.get("PACKAGE_NAME"));
info.setObjectName(map.get("OBJECT_NAME"));
info.setOverload(map.get("OVERLOAD"));
info.setSequence(map.get("SEQUENCE"));
info.setArgumentName(map.get("ARGUMENT_NAME"));
info.setInOut(map.get("IN_OUT"));
info.setDataType(map.get("DATA_TYPE"));
info.setDataLength(map.get("DATA_LENGTH"));
info.setDataPrecision(map.get("DATA_PRECISION"));
info.setDataScale(map.get("DATA_SCALE"));
// ARRAY and STRUCT only
final String typeOwner = map.get("TYPE_OWNER");
info.setTypeOwner(typeOwner);
// nullable
final String typeName = map.get("TYPE_NAME");
if (Srl.is_NotNull_and_NotTrimmedEmpty(typeName)) {
info.setTypeName(Srl.connectPrefix(typeName, typeOwner, "."));
}
info.setTypeSubName(map.get("TYPE_SUBNAME"));
infoList.add(info);
}
return infoList;
}
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 = new DfJdbcFacade(_dataSource);
final int countAll = facade.selectCountAll(tableSqlName);
if (countAll > _largeBorder) {
// it's large
large = true;
}
}
}
final String sql = buildExtractingSql(table);
if (large) {
return processLargeData(table, sql);
} else {
// mainly here
return processNormalData(table, sql);
}
}
use of org.dbflute.helper.jdbc.facade.DfJdbcFacade in project dbflute-core by dbflute.
the class DfJdbcFacadeTest method test_handleSQLException.
public void test_handleSQLException() throws Exception {
// ## Arrange ##
DfJdbcFacade facade = new DfJdbcFacade((DataSource) null);
String sql = "select * from dual";
SQLException e = new SQLException("foo message");
try {
// ## Act ##
facade.handleSQLException(sql, e);
// ## Assert ##
fail();
} catch (SQLFailureException actual) {
// OK
log(actual.getMessage());
assertEquals(e, actual.getCause());
}
}
Aggregations