Project

General

Profile

bug #4965

unsupported method getDatabase() in WrappedCdmDataSource breaks forceSchemaUpdate

Added by Andreas Kohlbecker almost 4 years ago. Updated over 2 years ago.

Status:
Closed
Priority:
Priority14
Category:
cdmlib
Target version:
Start date:
06/03/2015
Due date:
% Done:

100%

Severity:
normal
Found in Version:

Description

java.lang.UnsupportedOperationException: getDatabase() not supported by WrappedCdmDataSource
    at eu.etaxonomy.cdm.database.WrappedCdmDataSource.getDatabase(WrappedCdmDataSource.java:259)
    at eu.etaxonomy.cdm.database.update.UniqueIndexDropper.checkExists(UniqueIndexDropper.java:72)
    at eu.etaxonomy.cdm.database.update.UniqueIndexDropper.invokeOnTable(UniqueIndexDropper.java:50)
    at eu.etaxonomy.cdm.database.update.AuditedSchemaUpdaterStepBase.invoke(AuditedSchemaUpdaterStepBase.java:48)
    at eu.etaxonomy.cdm.database.update.UpdaterBase.handleSingleStep(UpdaterBase.java:177)
    at eu.etaxonomy.cdm.database.update.UpdaterBase.invoke(UpdaterBase.java:151)
    at eu.etaxonomy.cdm.database.update.UpdaterBase.invoke(UpdaterBase.java:89)
    at eu.etaxonomy.cdm.database.update.CdmUpdater.updateToCurrentVersion(CdmUpdater.java:116)
    at eu.etaxonomy.cdm.remote.config.DataSourceConfigurer.dataSource(DataSourceConfigurer.java:208)

this is another issue related to #3910

Associated revisions

Revision 0357b240 (diff)
Added by Andreas Kohlbecker almost 4 years ago

fixing #4965 unsupported method getDatabase() in WrappedCdmDataSource breaks forceSchemaUpdate

Revision 32e833cb (diff)
Added by Andreas Müller almost 3 years ago

#4965 Implement general solution for getDatabase() in
WrappedCdmDataSource

History

#1 Updated by Andreas Kohlbecker almost 4 years ago

databases are broken after an update failed like this.

#2 Updated by Andreas Müller almost 4 years ago

the problem is that java.util.Datasource does not bring any information about the database schema/catalog it connects to. Therefore

@Override
public String getDatabase() {
    throw new UnsupportedOperationException("getDatabase() not supported by WrappedCdmDataSource");
}

is not implemented.

Also connection.getMetaData().getCatalogs only provides a complete list of catalogs not the concrete database one is connected to.

In most cases one does not need to know such informations. However, when retrieving metadata about unique indexes (to be deleted) the database name is needed to find out the name of the index.

Need to do further research on how to retrieve the database name.

#3 Updated by Andreas Müller almost 4 years ago

Replying to a.kohlbecker:

databases are broken after an update failed like this.

yes, it is a known issue that databases are in an inconsistent state after one inbetween step fails. In this case you may shortly comment the following block in SchemaUpdater_35_36

//add hasMoreMembers
stepName = "Add hasMoreMembers to Team";
tableName = "AgentBase";
newColumnName = "hasMoreMembers";
step = ColumnAdder.NewBooleanInstance(stepName, tableName, newColumnName, INCLUDE_AUDIT, false);
stepList.add(step);

and update to the latest version to run the update successfully.

#4 Updated by Andreas Müller almost 4 years ago

  • Target version deleted ()

#5 Updated by Andreas Kohlbecker almost 4 years ago

you can use

((ComboPooledDataSource)dataSource).getJdbcUrl();

to get the jdbc url from which you can read the database name

#6 Updated by Andreas Kohlbecker almost 4 years ago

  • Status changed from New to Resolved

r24150 : implementing getDatabase() in WrappedCdmDataSource for ComboPooledDataSource

this allows us to use the forceSchemaUpdate option with almost all databases since we are almost exclusivity using the ComboPooledDataSource

shall we close the ticket?

#7 Updated by Andreas Müller almost 4 years ago

  • Status changed from Resolved to In Progress

This solution probably works only with MySQL but we should support at least all supported database types.

I just see that eu.etaxonomy.cdm.database.types.IDatabaseType has getDatabaseNameByConnectionString (String)

So if we know the datbase type we can use this method.

#8 Updated by Andreas Müller almost 4 years ago

  • Target version deleted (Release 3.7)
  • Priority changed from New to Highest

#9 Updated by Andreas Müller about 3 years ago

  • Target version changed from CDM UML 4.0 to CDM UML 4.1

#10 Updated by Andreas Müller almost 3 years ago

  • Priority changed from Highest to Priority14

#11 Updated by Andreas Müller almost 3 years ago

  • Status changed from In Progress to Resolved
  • Assignee changed from Andreas Müller to Andreas Kohlbecker

more general solution (for all supported database types) implemented by r28671

#12 Updated by Andreas Müller over 2 years ago

  • Description updated (diff)

Please review the latest change 32e833cb

#13 Updated by Andreas Kohlbecker over 2 years ago

  • Assignee changed from Andreas Kohlbecker to Andreas Müller
  • % Done changed from 0 to 100

#14 Updated by Andreas Kohlbecker over 2 years ago

  • Status changed from Resolved to Closed

#15 Updated by Andreas Müller over 2 years ago

  • Private changed from Yes to No

Also available in: Atom PDF

Add picture from clipboard (Maximum size: 40 MB)