use of org.dbflute.helper.jdbc.facade.DfJdbcFacade in project dbflute-core by dbflute.
the class DfSchemaInitializerJdbc method executeFirstSqlProcess.
protected void executeFirstSqlProcess(Connection conn, List<DfTableMeta> tableMetaList) {
if (_initializeFirstSqlList == null || _initializeFirstSqlList.isEmpty()) {
return;
}
final DfJdbcFacade jdbcFacade = new DfJdbcFacade(conn);
for (String firstSql : _initializeFirstSqlList) {
logReplaceSql(firstSql);
jdbcFacade.execute(firstSql);
}
}
use of org.dbflute.helper.jdbc.facade.DfJdbcFacade in project dbflute-core by dbflute.
the class DfSchemaInitializerPostgreSQL method dropSequence.
// ===================================================================================
// Drop Sequence
// =============
@Override
protected void dropSequence(Connection conn, List<DfTableMeta> tableMetaList) {
final String catalog = _unifiedSchema.existsPureCatalog() ? _unifiedSchema.getPureCatalog() : null;
final String schema = _unifiedSchema.getPureSchema();
final List<String> sequenceNameList = new ArrayList<String>();
final DfJdbcFacade jdbcFacade = new DfJdbcFacade(conn);
final String sequenceColumnName = "sequence_name";
final StringBuilder sb = new StringBuilder();
sb.append("select ").append(sequenceColumnName).append(" from information_schema.sequences");
sb.append(" where ");
if (Srl.is_NotNull_and_NotTrimmedEmpty(catalog)) {
sb.append("sequence_catalog = '").append(catalog).append("'").append(" and ");
}
sb.append("sequence_schema = '").append(schema).append("'");
final String sql = sb.toString();
final List<String> sequenceColumnList = Arrays.asList(sequenceColumnName);
final List<Map<String, String>> resultList = jdbcFacade.selectStringList(sql, sequenceColumnList);
for (Map<String, String> recordMap : resultList) {
sequenceNameList.add(recordMap.get(sequenceColumnName));
}
for (String sequenceName : sequenceNameList) {
if (isSequenceExcept(sequenceName)) {
continue;
}
final String sequenceSqlName = _unifiedSchema.buildSqlName(sequenceName);
final String dropSequenceSql = "drop sequence " + sequenceSqlName;
logReplaceSql(dropSequenceSql);
jdbcFacade.execute(dropSequenceSql);
}
}
use of org.dbflute.helper.jdbc.facade.DfJdbcFacade in project dbflute-core by dbflute.
the class DfArrayExtractorOracle method selectSimpleArray.
protected List<Map<String, String>> selectSimpleArray(UnifiedSchema unifiedSchema) {
final DfJdbcFacade facade = new DfJdbcFacade(_dataSource);
final List<String> columnList = new ArrayList<String>();
columnList.add("TYPE_NAME");
final String sql = buildSimpleArraySql(unifiedSchema);
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 simple array info: " + continued.getMessage());
return DfCollectionUtil.emptyList();
}
return resultList;
}
use of org.dbflute.helper.jdbc.facade.DfJdbcFacade in project dbflute-core by dbflute.
the class DfDatetimePrecisionExtractorMySQL method extractDatetimePrecisionMap.
public Map<String, Map<String, Integer>> extractDatetimePrecisionMap(Set<String> tableSet) {
try {
final Map<String, Map<String, Integer>> precisionMap = StringKeyMap.createAsFlexibleOrdered();
final DfJdbcFacade facade = new DfJdbcFacade(_dataSource);
final List<String> columnList = DfCollectionUtil.newArrayList("TABLE_NAME", "COLUMN_NAME", "DATETIME_PRECISION");
final StringBuilder sb = new StringBuilder();
sb.append("select ").append(Srl.connectByDelimiter(columnList, ", "));
sb.append(" from INFORMATION_SCHEMA.COLUMNS");
sb.append(" where TABLE_SCHEMA = '").append(_unifiedSchema.getPureCatalog()).append("'");
// unneeded (use if performance problem at future)
// if (!tableSet.isEmpty()) { // just in case
// sb.append(" and TABLE_NAME in ('").append(Srl.connectByDelimiter(tableSet, "', '")).append("')");
// }
sb.append(" and DATA_TYPE = 'datetime'");
final String sql = sb.toString();
_log.info(sql);
final List<Map<String, String>> resultList = facade.selectStringList(sql, columnList);
for (Map<String, String> recordMap : resultList) {
final String tableName = recordMap.get("TABLE_NAME");
final String columnName = recordMap.get("COLUMN_NAME");
final String datetimePrecision = recordMap.get("DATETIME_PRECISION");
Map<String, Integer> columnMap = precisionMap.get(tableName);
if (columnMap == null) {
columnMap = StringKeyMap.createAsFlexibleOrdered();
precisionMap.put(tableName, columnMap);
}
columnMap.put(columnName, Integer.valueOf(datetimePrecision));
}
return precisionMap;
} catch (RuntimeException continued) {
_log.info("Failed to select date-time precision, so you cannot use date precision option.", continued);
return Collections.emptyMap();
}
}
use of org.dbflute.helper.jdbc.facade.DfJdbcFacade in project dbflute-core by dbflute.
the class DfProcedureSynonymExtractorOracle method judgeSynonymSelectable.
protected void judgeSynonymSelectable(DfSynonymMeta info) {
final DfJdbcFacade facade = new DfJdbcFacade(_dataSource);
final String synonymSqlName = info.buildSynonymSqlName();
final String sql = "select * from " + synonymSqlName + " where 0=1";
try {
final List<String> columnList = new ArrayList<String>();
columnList.add("dummy");
facade.selectStringList(sql, columnList);
info.setSelectable(true);
} catch (RuntimeException ignored) {
info.setSelectable(false);
}
}
Aggregations