dirksm/c5-db-migration

[DataSourceMigrationManager] Constructor threw exception if no JDBC Connection is available at instantiation time.

Closed this issue · 3 comments

Construction of DataSourceMigrationManager instances fails if no
JDBC-Connection could be established (e.g. the DB is down) because of
DatabaseType lookup even if the DatabaseType is provided as argument!

Actually there are two constructor provided:

    public DataSourceMigrationManager(DataSource dataSource)
    {
        this.jdbcTemplate = new JdbcTemplate(dataSource);
        this.dbType = determineDatabaseType();
    }

    public DataSourceMigrationManager(DataSource dataSource, DatabaseType
dbType)
    {
        this(dataSource);
        this.dbType = dbType;
    }

The second calls the first one and triggers transparently the
determineDatabaseType method call. Maybe the following structure make more
sense:

    public DataSourceMigrationManager(DataSource dataSource)
    {
        this(dataSource, determineDatabaseType());
    }

    public DataSourceMigrationManager(DataSource dataSource, DatabaseType
dbType)
    {
        this.jdbcTemplate = new JdbcTemplate(dataSource);
        this.dbType = dbType;
    }


Best regards,
Tobias Joch

Original issue reported on code.google.com by vespa...@googlemail.com on 9 Mar 2010 at 1:41

Original comment by christia...@gmail.com on 18 Mar 2010 at 6:34

  • Changed state: Accepted

Original comment by christia...@gmail.com on 18 Mar 2010 at 6:34

  • Changed state: Started
Went witha slightly different implementation, since you can't invoke a method 
before 
the super() call has been invoked... it solves the problem though.  Thanks!

Original comment by christia...@gmail.com on 18 Mar 2010 at 6:50

  • Changed state: Fixed