Search in sources :

Example 1 with DfTableExtractor

use of org.dbflute.logic.jdbc.metadata.basic.DfTableExtractor in project dbflute-core by dbflute.

the class DfSequenceHandlerJdbc method initializeTableInfo.

protected void initializeTableInfo(Connection conn) throws SQLException {
    if (_tableMap != null) {
        return;
    }
    _tableMap = StringKeyMap.createAsFlexible();
    final DfTableExtractor tableHandler = new DfTableExtractor();
    final DatabaseMetaData metaData = conn.getMetaData();
    final List<UnifiedSchema> unifiedSchemaList = _unifiedSchemaList;
    for (UnifiedSchema unifiedSchema : unifiedSchemaList) {
        // same-name tables between different schemas are unsupported
        // so put all directly here
        _tableMap.putAll(tableHandler.getTableMap(metaData, unifiedSchema));
    }
}
Also used : DfTableExtractor(org.dbflute.logic.jdbc.metadata.basic.DfTableExtractor) UnifiedSchema(org.apache.torque.engine.database.model.UnifiedSchema) DatabaseMetaData(java.sql.DatabaseMetaData)

Example 2 with DfTableExtractor

use of org.dbflute.logic.jdbc.metadata.basic.DfTableExtractor in project dbflute-core by dbflute.

the class DfConventionalTakeAsserter method extractTableList.

protected List<DfTableMeta> extractTableList() {
    Connection conn = null;
    try {
        conn = _dataSource.getConnection();
        final DatabaseMetaData metaData = conn.getMetaData();
        return new DfTableExtractor().getTableList(metaData, _dataSource.getSchema());
    } catch (SQLException e) {
        throw new SQLFailureException("Failed to extract table meta list: " + _dataSource, e);
    } finally {
        if (conn != null) {
            try {
                conn.close();
            } catch (SQLException ignored) {
            }
        }
    }
}
Also used : DfTableExtractor(org.dbflute.logic.jdbc.metadata.basic.DfTableExtractor) SQLException(java.sql.SQLException) Connection(java.sql.Connection) DatabaseMetaData(java.sql.DatabaseMetaData) SQLFailureException(org.dbflute.exception.SQLFailureException)

Example 3 with DfTableExtractor

use of org.dbflute.logic.jdbc.metadata.basic.DfTableExtractor in project dbflute-core by dbflute.

the class DfSchemaInitializerJdbc method initializeSchema.

// ===================================================================================
// Initialize Schema
// =================
public void initializeSchema() {
    Connection conn = null;
    try {
        try {
            conn = _dataSource.getConnection();
        } catch (SQLException e) {
            if (_suppressConnectionFailure) {
                handleSuppressedConnectionFailure(e);
                return;
            } else {
                throw e;
            }
        }
        final List<DfTableMeta> tableMetaList;
        try {
            final DatabaseMetaData metaData = conn.getMetaData();
            final DfTableExtractor tableExtractor = createDropTableExtractor();
            tableMetaList = tableExtractor.getTableList(metaData, _unifiedSchema);
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
        executeObject(conn, tableMetaList);
    } catch (SQLException e) {
        String msg = "Failed to the initialize schema: " + _unifiedSchema;
        throw new SQLFailureException(msg, e);
    } finally {
        if (conn != null) {
            try {
                conn.close();
            } catch (SQLException ignored) {
                _log.info("connection.close() threw the exception!", ignored);
            }
        }
    }
}
Also used : SQLException(java.sql.SQLException) DfTableExtractor(org.dbflute.logic.jdbc.metadata.basic.DfTableExtractor) Connection(java.sql.Connection) DfTableMeta(org.dbflute.logic.jdbc.metadata.info.DfTableMeta) DatabaseMetaData(java.sql.DatabaseMetaData) SQLFailureException(org.dbflute.exception.SQLFailureException)

Example 4 with DfTableExtractor

use of org.dbflute.logic.jdbc.metadata.basic.DfTableExtractor in project dbflute-core by dbflute.

the class DfRepsSequenceHandlerJdbc method initializeTableInfo.

protected void initializeTableInfo(Connection conn) throws SQLException {
    if (_tableMap != null) {
        return;
    }
    _tableMap = StringKeyMap.createAsFlexible();
    final DfTableExtractor tableHandler = new DfTableExtractor();
    final DatabaseMetaData metaData = conn.getMetaData();
    final List<UnifiedSchema> unifiedSchemaList = _unifiedSchemaList;
    for (UnifiedSchema unifiedSchema : unifiedSchemaList) {
        // same-name tables between different schemas are unsupported
        // so put all directly here
        _tableMap.putAll(tableHandler.getTableMap(metaData, unifiedSchema));
    }
}
Also used : DfTableExtractor(org.dbflute.logic.jdbc.metadata.basic.DfTableExtractor) UnifiedSchema(org.apache.torque.engine.database.model.UnifiedSchema) DatabaseMetaData(java.sql.DatabaseMetaData)

Aggregations

DatabaseMetaData (java.sql.DatabaseMetaData)4 DfTableExtractor (org.dbflute.logic.jdbc.metadata.basic.DfTableExtractor)4 Connection (java.sql.Connection)2 SQLException (java.sql.SQLException)2 UnifiedSchema (org.apache.torque.engine.database.model.UnifiedSchema)2 SQLFailureException (org.dbflute.exception.SQLFailureException)2 DfTableMeta (org.dbflute.logic.jdbc.metadata.info.DfTableMeta)1