Revision 974ae00d
Added by Andreas Kohlbecker over 7 years ago
src/test/java/eu/etaxonomy/cdm/remote/config/DataSourceConfigurer.java | ||
---|---|---|
1 |
// $Id$ |
|
2 | 1 |
/** |
3 | 2 |
* Copyright (C) 2009 EDIT |
4 | 3 |
* European Distributed Institute of Taxonomy |
... | ... | |
36 | 35 |
import com.mchange.v2.c3p0.ComboPooledDataSource; |
37 | 36 |
|
38 | 37 |
import eu.etaxonomy.cdm.common.CdmUtils; |
38 |
import eu.etaxonomy.cdm.database.WrappedCdmDataSource; |
|
39 |
import eu.etaxonomy.cdm.database.update.CdmUpdater; |
|
39 | 40 |
import eu.etaxonomy.cdm.model.metadata.CdmMetaData; |
40 | 41 |
import eu.etaxonomy.cdm.model.metadata.CdmMetaData.MetaDataPropertyName; |
41 | 42 |
|
... | ... | |
161 | 162 |
try { |
162 | 163 |
|
163 | 164 |
Connection connection = dataSource.getConnection(); |
164 |
ResultSet tables = connection.getMetaData().getTables(connection.getCatalog(), null, "CdmMetaData", null); |
|
165 |
String metadataTableName = "CdmMetaData"; |
|
166 |
if(inferHibernateDialectName(dataSource).equals(H2CorrectedDialect.class.getName())){ |
|
167 |
metadataTableName = metadataTableName.toUpperCase(); |
|
168 |
} |
|
169 |
ResultSet tables = connection.getMetaData().getTables(connection.getCatalog(), null, metadataTableName, null); |
|
165 | 170 |
if(tables.first()){ |
166 | 171 |
ResultSet resultSet = connection.createStatement().executeQuery(MetaDataPropertyName.DB_SCHEMA_VERSION.getSqlQuery()); |
167 | 172 |
String version = null; |
... | ... | |
199 | 204 |
|
200 | 205 |
String forceSchemaUpdate = findProperty(ATTRIBUTE_FORCE_SCHEMA_UPDATE, false); |
201 | 206 |
if(forceSchemaUpdate != null){ |
202 |
logger.error("Unable to update data source due to #3910 (eu.etaxonomy.cdm.database.ICdmDataSource is not compatible to javax.sql.DataSource)"); |
|
203 |
/* |
|
204 |
* DISABLED due to #3910 (eu.etaxonomy.cdm.database.ICdmDataSource is not compatible to javax.sql.DataSource) |
|
205 |
* CdmUpdater updater = CdmUpdater.NewInstance(); |
|
206 |
String hiernateDialectName = inferHibernateDialectName(dataSource); |
|
207 |
DatabaseTypeEnum dbType = null; |
|
208 |
if(hiernateDialectName.equals(MySQL5MyISAMUtf8Dialect.class.getName())) { |
|
209 |
dbType = DatabaseTypeEnum.MySQL; |
|
210 |
} |
|
211 |
RuntimeException re = new RuntimeException("Unable to update data source, CdmUpdater.updateToCurrentVersion() cannot use javax.sql.DataSource or javax.sql.DataSource"); |
|
212 |
|
|
213 |
CdmDataSource cdmDataSource = CdmDataSource.NewInstance(dbType, dataSource.ge, database, username, password) |
|
214 |
updater.updateToCurrentVersion(dataSource, null); |
|
215 |
*/ |
|
207 |
logger.info("Update of data source requested by property '" + ATTRIBUTE_FORCE_SCHEMA_UPDATE + "'"); |
|
216 | 208 |
|
209 |
CdmUpdater updater = CdmUpdater.NewInstance(); |
|
210 |
WrappedCdmDataSource cdmDataSource = new WrappedCdmDataSource(dataSource); |
|
211 |
updater.updateToCurrentVersion(cdmDataSource, null); |
|
217 | 212 |
} |
218 | 213 |
|
219 | 214 |
return dataSource; |
Also available in: Unified diff
updating DataSourceConfigurer with new code from cdmlib-remote - THIS IS REALLY UGLY!