Search in sources :

Example 1 with DfDataSourceHandler

use of org.dbflute.helper.jdbc.connection.DfDataSourceHandler in project dbflute-core by dbflute.

the class DfSchemaSyncChecker method prepareTargetDataSource.

protected DataSource prepareTargetDataSource() {
    final DfDataSourceHandler handler = new DfDataSourceHandler();
    // inherit
    handler.setDriver(getDatabaseProperties().getDatabaseDriver());
    final String url = getDocumentProperties().getSchemaSyncCheckDatabaseUrl();
    // may inherit
    handler.setUrl(url);
    final String user = getDocumentProperties().getSchemaSyncCheckDatabaseUser();
    if (Srl.is_Null_or_TrimmedEmpty(user)) {
        // just in case
        String msg = "The user for sync target schema was not found: " + user;
        throw new IllegalStateException(msg);
    }
    handler.setUser(user);
    handler.setPassword(getDocumentProperties().getSchemaSyncCheckDatabasePassword());
    // inherit
    handler.setConnectionProperties(getDatabaseProperties().getConnectionProperties());
    handler.setAutoCommit(true);
    _log.info("...Preparing data source for SchemaSyncCheck target:");
    _log.info("  url  = " + url);
    _log.info("  user = " + user);
    return new DfFittingDataSource(handler);
}
Also used : DfFittingDataSource(org.dbflute.helper.jdbc.connection.DfFittingDataSource) DfDataSourceHandler(org.dbflute.helper.jdbc.connection.DfDataSourceHandler)

Example 2 with DfDataSourceHandler

use of org.dbflute.helper.jdbc.connection.DfDataSourceHandler in project dbflute-core by dbflute.

the class DfTaskControlLogic method setupDataSource.

// ===================================================================================
// Data Source
// ===========
public void setupDataSource() throws SQLException {
    final DfDataSourceHandler dataSourceHandler = _databaseResource.getDataSourceHandler();
    dataSourceHandler.setUser(_databaseResource.getUser());
    dataSourceHandler.setPassword(_databaseResource.getPassword());
    dataSourceHandler.setDriver(_databaseResource.getDriver());
    dataSourceHandler.setUrl(_databaseResource.getUrl());
    dataSourceHandler.setConnectionProperties(_databaseResource.getConnectionProperties());
    dataSourceHandler.setAutoCommit(true);
    dataSourceHandler.addConnectionCreationHook(new DfConnectionCreationHook() {

        public void hook(Connection conn) throws SQLException {
            connectMainSchema(conn);
        }
    });
    dataSourceHandler.prepare();
}
Also used : SQLException(java.sql.SQLException) Connection(java.sql.Connection) DfConnectionCreationHook(org.dbflute.helper.jdbc.connection.DfConnectionCreationHook) DfDataSourceHandler(org.dbflute.helper.jdbc.connection.DfDataSourceHandler)

Example 3 with DfDataSourceHandler

use of org.dbflute.helper.jdbc.connection.DfDataSourceHandler in project dbflute-core by dbflute.

the class DfTaskControlLogic method commitDataSource.

public void commitDataSource() throws SQLException {
    final DfDataSourceHandler dataSourceHandler = _databaseResource.getDataSourceHandler();
    dataSourceHandler.commit();
}
Also used : DfDataSourceHandler(org.dbflute.helper.jdbc.connection.DfDataSourceHandler)

Example 4 with DfDataSourceHandler

use of org.dbflute.helper.jdbc.connection.DfDataSourceHandler in project dbflute-core by dbflute.

the class DfTaskControlLogic method destroyDataSource.

public void destroyDataSource() throws SQLException {
    final DfDataSourceHandler dataSourceHandler = _databaseResource.getDataSourceHandler();
    dataSourceHandler.destroy();
    if (getDatabaseTypeFacadeProp().isDatabaseDerby()) {
        // Derby(Embedded) needs an original shutdown for destroying a connection
        DfDBFluteTaskUtil.shutdownIfDerbyEmbedded(_databaseResource.getDriver());
    }
}
Also used : DfDataSourceHandler(org.dbflute.helper.jdbc.connection.DfDataSourceHandler)

Aggregations

DfDataSourceHandler (org.dbflute.helper.jdbc.connection.DfDataSourceHandler)4 Connection (java.sql.Connection)1 SQLException (java.sql.SQLException)1 DfConnectionCreationHook (org.dbflute.helper.jdbc.connection.DfConnectionCreationHook)1 DfFittingDataSource (org.dbflute.helper.jdbc.connection.DfFittingDataSource)1