Search in sources :

Example 16 with DfUrlAnalyzer

use of org.dbflute.logic.jdbc.urlanalyzer.DfUrlAnalyzer in project dbflute-core by dbflute.

the class DfUrlAnalyzerSQLiteTest method test_extractCatalog_option.

public void test_extractCatalog_option() throws Exception {
    // ## Arrange ##
    DfUrlAnalyzer analyzer = createTarget("jdbc:sqlite:../src/main/resources/ponpon/exampledb.db;charSet=UTF-8");
    // ## Act ##
    String catalog = analyzer.extractCatalog();
    // ## Assert ##
    assertEquals("exampledb", catalog);
}
Also used : DfUrlAnalyzer(org.dbflute.logic.jdbc.urlanalyzer.DfUrlAnalyzer)

Example 17 with DfUrlAnalyzer

use of org.dbflute.logic.jdbc.urlanalyzer.DfUrlAnalyzer in project dbflute-core by dbflute.

the class DfUrlAnalyzerSQLiteTest method test_extractCatalog_basic.

public void test_extractCatalog_basic() throws Exception {
    // ## Arrange ##
    DfUrlAnalyzer analyzer = createTarget("jdbc:sqlite:../src/main/resources/ponpon/exampledb.db");
    // ## Act ##
    String catalog = analyzer.extractCatalog();
    // ## Assert ##
    assertEquals("exampledb", catalog);
}
Also used : DfUrlAnalyzer(org.dbflute.logic.jdbc.urlanalyzer.DfUrlAnalyzer)

Example 18 with DfUrlAnalyzer

use of org.dbflute.logic.jdbc.urlanalyzer.DfUrlAnalyzer in project dbflute-core by dbflute.

the class DfReplaceSchemaProperties method createAdditionalUserConnection.

public Connection createAdditionalUserConnection(String additonalUser) {
    final Map<String, String> propertyMap = getAdditionalUserPropertyMap(additonalUser);
    if (propertyMap == null) {
        return null;
    }
    final String title = "replaceSchemaDefinitionMap#additionalUserMap$";
    final String driver = getDatabaseProperties().getDatabaseDriver();
    final String url;
    {
        String property = resolveDispatchVariable(title + "url", propertyMap.get("url"));
        if (property != null && property.trim().length() > 0) {
            url = property;
        } else {
            url = getDatabaseProperties().getDatabaseUrl();
        }
    }
    final DfUrlAnalyzerFactory factory = new DfUrlAnalyzerFactory(getBasicProperties(), url);
    final DfUrlAnalyzer analyzer = factory.createAnalyzer();
    final String catalog = analyzer.extractCatalog();
    final String schema = propertyMap.get("schema");
    final UnifiedSchema unifiedSchema = UnifiedSchema.createAsDynamicSchema(catalog, schema);
    final String user = resolveDispatchVariable(title + "user", propertyMap.get("user"));
    final String password = resolvePasswordVariable(title + "password", additonalUser, propertyMap.get("password"));
    final Properties prop = getDatabaseProperties().getConnectionProperties();
    prop.setProperty("user", user);
    prop.setProperty("password", password);
    _log.info("...Creating a connection for additional user: " + user);
    return createConnection(driver, url, unifiedSchema, prop);
}
Also used : DfUrlAnalyzer(org.dbflute.logic.jdbc.urlanalyzer.DfUrlAnalyzer) UnifiedSchema(org.apache.torque.engine.database.model.UnifiedSchema) Properties(java.util.Properties) DfConnectionProperties(org.dbflute.properties.assistant.database.DfConnectionProperties) DfUrlAnalyzerFactory(org.dbflute.logic.jdbc.urlanalyzer.factory.DfUrlAnalyzerFactory)

Example 19 with DfUrlAnalyzer

use of org.dbflute.logic.jdbc.urlanalyzer.DfUrlAnalyzer in project dbflute-core by dbflute.

the class DfDatabaseProperties method extractCatalogFromUrl.

public String extractCatalogFromUrl(String url) {
    final DfUrlAnalyzerFactory factory = new DfUrlAnalyzerFactory(getBasicProperties(), url);
    final DfUrlAnalyzer analyzer = factory.createAnalyzer();
    final String extracted = analyzer.extractCatalog();
    return Srl.is_NotNull_and_NotTrimmedEmpty(extracted) ? extracted : null;
}
Also used : DfUrlAnalyzer(org.dbflute.logic.jdbc.urlanalyzer.DfUrlAnalyzer) DfUrlAnalyzerFactory(org.dbflute.logic.jdbc.urlanalyzer.factory.DfUrlAnalyzerFactory)

Example 20 with DfUrlAnalyzer

use of org.dbflute.logic.jdbc.urlanalyzer.DfUrlAnalyzer in project dbflute-core by dbflute.

the class DfUrlAnalyzerPostgreSQLTest method test_extractCatalog_nohost.

public void test_extractCatalog_nohost() throws Exception {
    // ## Arrange ##
    DfUrlAnalyzer analyzer = createTarget("jdbc:postgresql:exampledb");
    // ## Act ##
    String catalog = analyzer.extractCatalog();
    // ## Assert ##
    assertEquals("exampledb", catalog);
}
Also used : DfUrlAnalyzer(org.dbflute.logic.jdbc.urlanalyzer.DfUrlAnalyzer)

Aggregations

DfUrlAnalyzer (org.dbflute.logic.jdbc.urlanalyzer.DfUrlAnalyzer)33 DfUrlAnalyzerFactory (org.dbflute.logic.jdbc.urlanalyzer.factory.DfUrlAnalyzerFactory)3 UnifiedSchema (org.apache.torque.engine.database.model.UnifiedSchema)2 Properties (java.util.Properties)1 DfRequiredPropertyNotFoundException (org.dbflute.exception.DfRequiredPropertyNotFoundException)1 DfConnectionProperties (org.dbflute.properties.assistant.database.DfConnectionProperties)1