awferreira / c5-db-migration

Automatically exported from code.google.com/p/c5-db-migration
0 stars 0 forks source link

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

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
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

GoogleCodeExporter commented 8 years ago

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

GoogleCodeExporter commented 8 years ago

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

GoogleCodeExporter commented 8 years ago
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