diff options
15 files changed, 209 insertions, 83 deletions
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/CDODBBrowser.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/CDODBBrowser.java index 1d0f1b0491..8332ac1d88 100644 --- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/CDODBBrowser.java +++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/CDODBBrowser.java @@ -10,11 +10,13 @@ */ package org.eclipse.emf.cdo.server.db; +import org.eclipse.emf.cdo.server.IStore; import org.eclipse.emf.cdo.server.internal.db.bundle.OM; import org.eclipse.emf.cdo.spi.server.InternalRepository; import org.eclipse.net4j.db.DBException; import org.eclipse.net4j.db.DBUtil; +import org.eclipse.net4j.db.IDBConnectionProvider; import org.eclipse.net4j.util.StringUtil; import org.eclipse.net4j.util.concurrent.Worker; import org.eclipse.net4j.util.container.ContainerEventAdapter; @@ -47,7 +49,6 @@ import java.util.Set; * @author Eike Stepper * @since 3.0 */ -@SuppressWarnings("nls") public class CDODBBrowser extends Worker { private static final String REQUEST_PREFIX = "GET "; @@ -274,38 +275,42 @@ public class CDODBBrowser extends Worker InternalRepository repository = repositories.get(repo); if (repository != null) { - IDBStore store = (IDBStore)repository.getStore(); - Connection connection = null; - - try + IStore store = repository.getStore(); + if (store instanceof IDBConnectionProvider) { - connection = store.getDBConnectionProvider().getConnection(); + IDBConnectionProvider connectionProvider = (IDBConnectionProvider)store; + Connection connection = null; - pout.print("<p>\r\n"); - pout.print("<table border=\"0\">\r\n"); - pout.print("<tr>\r\n"); + try + { + connection = connectionProvider.getConnection(); - pout.print("<td valign=\"top\">\r\n"); - showTables(pout, connection, repo); - pout.print("</td>\r\n"); + pout.print("<p>\r\n"); + pout.print("<table border=\"0\">\r\n"); + pout.print("<tr>\r\n"); - if (table != null) - { pout.print("<td valign=\"top\">\r\n"); - showTable(pout, connection); + showTables(pout, connection, repo); pout.print("</td>\r\n"); - } - pout.print("</tr>\r\n"); - pout.print("</table>\r\n"); - } - catch (DBException ex) - { - ex.printStackTrace(); - } - finally - { - DBUtil.close(connection); + if (table != null) + { + pout.print("<td valign=\"top\">\r\n"); + showTable(pout, connection); + pout.print("</td>\r\n"); + } + + pout.print("</tr>\r\n"); + pout.print("</table>\r\n"); + } + catch (DBException ex) + { + ex.printStackTrace(); + } + finally + { + DBUtil.close(connection); + } } } } @@ -317,7 +322,7 @@ public class CDODBBrowser extends Worker List<String> allTableNames = DBUtil.getAllTableNames(connection, repo); for (String tableName : allTableNames) { - String label = escape(tableName).toLowerCase(); + String label = escape(tableName)/* .toLowerCase() */; if (tableName.equals(table)) { pout.print("<b>" + label + "</b><br>\r\n"); @@ -335,7 +340,7 @@ public class CDODBBrowser extends Worker try { String order = getParam("order"); - executeQuery(pout, connection, "SELECT * FROM " + table + executeQuery(pout, connection, "SELECT * FROM \"" + table + "\"" + (order == null ? "" : " ORDER BY " + order + " " + getParam("direction"))); } catch (Exception ex) @@ -367,7 +372,7 @@ public class CDODBBrowser extends Worker pout.print("<td> </td>\r\n"); for (int i = 0; i < columns; i++) { - String column = metaData.getColumnLabel(1 + i).toLowerCase(); + String column = metaData.getColumnLabel(1 + i)/* .toLowerCase() */; String dir = column.equals(order) && "ASC".equals(direction) ? "DESC" : "ASC"; pout.print("<td><b>" + href(column, "data", "order", column, "direction", dir) + "</b></td>\r\n"); } diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IDBStore.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IDBStore.java index 55b783163c..e3420bea0d 100644 --- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IDBStore.java +++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IDBStore.java @@ -4,10 +4,10 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html - * + * * Contributors: * Eike Stepper - initial API and implementation - * Stefan Winkler - 271444: [DB] Multiple refactorings + * Stefan Winkler - 271444: [DB] Multiple refactorings * Stefan Winkler - 249610: [DB] Support external references (Implementation) */ package org.eclipse.emf.cdo.server.db; @@ -24,7 +24,7 @@ import org.eclipse.net4j.db.ddl.IDBSchema; /** * @author Eike Stepper */ -public interface IDBStore extends IStore +public interface IDBStore extends IStore, IDBConnectionProvider { /** * @since 2.0 @@ -36,11 +36,6 @@ public interface IDBStore extends IStore public IDBAdapter getDBAdapter(); /** - * @since 2.0 - */ - public IDBConnectionProvider getDBConnectionProvider(); - - /** * Get the meta data manager associated with this DBStore. * * @since 2.0 diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStore.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStore.java index 0fe72fcd33..1ccd7f46a3 100644 --- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStore.java +++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStore.java @@ -153,9 +153,24 @@ public class DBStore extends LongIDStore implements IDBStore, CDOAllRevisionsPro this.dbAdapter = dbAdapter; } - public IDBConnectionProvider getDBConnectionProvider() + public Connection getConnection() { - return dbConnectionProvider; + Connection connection = dbConnectionProvider.getConnection(); + if (connection == null) + { + throw new DBException("No connection from connection provider: " + dbConnectionProvider); //$NON-NLS-1$ + } + + try + { + connection.setAutoCommit(false); + } + catch (SQLException ex) + { + throw new DBException(ex); + } + + return connection; } public void setDbConnectionProvider(IDBConnectionProvider dbConnectionProvider) @@ -347,26 +362,6 @@ public class DBStore extends LongIDStore implements IDBStore, CDOAllRevisionsPro return new DBStoreAccessor(this, transaction); } - protected Connection getConnection() - { - Connection connection = dbConnectionProvider.getConnection(); - if (connection == null) - { - throw new DBException("No connection from connection provider: " + dbConnectionProvider); //$NON-NLS-1$ - } - - try - { - connection.setAutoCommit(false); - } - catch (SQLException ex) - { - throw new DBException(ex); - } - - return connection; - } - public Map<CDOBranch, List<CDORevision>> getAllRevisions() { final Map<CDOBranch, List<CDORevision>> result = new HashMap<CDOBranch, List<CDORevision>>(); @@ -417,8 +412,8 @@ public class DBStore extends LongIDStore implements IDBStore, CDOAllRevisionsPro checkNull(dbAdapter, Messages.getString("DBStore.1")); //$NON-NLS-1$ checkNull(dbConnectionProvider, Messages.getString("DBStore.0")); //$NON-NLS-1$ - checkState(getRevisionTemporality() == RevisionTemporality.AUDITING == mappingStrategy.hasAuditSupport(), Messages - .getString("DBStore.7")); //$NON-NLS-1$ + checkState(getRevisionTemporality() == RevisionTemporality.AUDITING == mappingStrategy.hasAuditSupport(), + Messages.getString("DBStore.7")); //$NON-NLS-1$ checkState(getRevisionParallelism() == RevisionParallelism.BRANCHING == mappingStrategy.hasBranchingSupport(), Messages.getString("DBStore.11")); //$NON-NLS-1$ diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/META-INF/MANIFEST.MF b/plugins/org.eclipse.emf.cdo.server.hibernate/META-INF/MANIFEST.MF index 27cfe4d07c..e0d2fa7e5c 100644 --- a/plugins/org.eclipse.emf.cdo.server.hibernate/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.emf.cdo.server.hibernate/META-INF/MANIFEST.MF @@ -11,7 +11,8 @@ Bundle-RequiredExecutionEnvironment: J2SE-1.5 Bundle-ClassPath: . Eclipse-BuddyPolicy: registered Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.4.0,4.0.0)", - org.eclipse.emf.cdo.server;bundle-version="[3.0.0,4.0.0)";visibility:=reexport + org.eclipse.emf.cdo.server;bundle-version="[3.0.0,4.0.0)";visibility:=reexport, + org.eclipse.net4j.db;bundle-version="[3.0.0,4.0.0)";visibility:=reexport Export-Package: org.eclipse.emf.cdo.server.hibernate;version="3.0.0", org.eclipse.emf.cdo.server.internal.hibernate;version="3.0.0";x-friends:="org.eclipse.emf.cdo.server.hibernate.teneo,org.eclipse.emf.cdo.tests.hibernate", org.eclipse.emf.cdo.server.internal.hibernate.bundle;version="3.0.0";x-internal:=true, diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/hibernate/IHibernateStore.java b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/hibernate/IHibernateStore.java index aac50a9881..5900f19b4a 100644 --- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/hibernate/IHibernateStore.java +++ b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/hibernate/IHibernateStore.java @@ -4,7 +4,7 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html - * + * * Contributors: * Eike Stepper - initial API and implementation */ @@ -12,13 +12,15 @@ package org.eclipse.emf.cdo.server.hibernate; import org.eclipse.emf.cdo.server.IStore; +import org.eclipse.net4j.db.IDBConnectionProvider; + import org.hibernate.SessionFactory; import org.hibernate.cfg.Configuration; /** * @author Eike Stepper */ -public interface IHibernateStore extends IStore +public interface IHibernateStore extends IStore, IDBConnectionProvider { public Configuration getHibernateConfiguration(); diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernatePackageHandler.java b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernatePackageHandler.java index 38b8a8fc0b..f03ec07184 100644 --- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernatePackageHandler.java +++ b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernatePackageHandler.java @@ -36,6 +36,7 @@ import org.hibernate.cfg.Environment; import org.hibernate.tool.hbm2ddl.SchemaExport; import org.hibernate.tool.hbm2ddl.SchemaUpdate; +import java.io.File; import java.io.InputStream; import java.util.ArrayList; import java.util.Collection; @@ -387,26 +388,27 @@ public class HibernatePackageHandler extends Lifecycle session.beginTransaction(); try { + System.out.println(new File(".").getAbsolutePath()); final Criteria c = session.createCriteria(SystemInformation.class); List<?> l = c.list(); + int records = l.size(); final SystemInformation systemInformation; - if (l.size() == 0) + if (records == 0) { systemInformation = new SystemInformation(); systemInformation.setFirstTime(true); systemInformation.setCreationTime(System.currentTimeMillis()); session.saveOrUpdate(systemInformation); } - else if (l.size() > 1) + else if (records == 1) { - throw new IllegalStateException( - "More than one records in the cdo_system_information table, this is an illegal situation"); //$NON-NLS-1$ + systemInformation = (SystemInformation)l.get(0); + systemInformation.setFirstTime(false); } else { - systemInformation = (SystemInformation)l.get(0); - systemInformation.setFirstTime(false); + throw new IllegalStateException("More than one record in the cdo_system_information table"); } return systemInformation; diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateStore.java b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateStore.java index 41d7a22eed..db4df5f2fb 100644 --- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateStore.java +++ b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateStore.java @@ -25,6 +25,7 @@ import org.eclipse.emf.cdo.server.internal.hibernate.tuplizer.CDOInterceptor; import org.eclipse.emf.cdo.spi.server.Store; import org.eclipse.emf.cdo.spi.server.StoreAccessorPool; +import org.eclipse.net4j.db.DBException; import org.eclipse.net4j.util.WrappedException; import org.eclipse.net4j.util.io.IOUtil; import org.eclipse.net4j.util.lifecycle.LifecycleUtil; @@ -40,6 +41,9 @@ import org.hibernate.mapping.PersistentClass; import org.hibernate.tool.hbm2ddl.SchemaExport; import java.io.InputStream; +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.SQLException; import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; @@ -261,6 +265,34 @@ public class HibernateStore extends Store implements IHibernateStore return hibernateSessionFactory; } + public Connection getConnection() + { + String connectionURL = getProperties().getProperty("hibernate.connection.url"); + String userName = getProperties().getProperty("hibernate.connection.username"); + String passWord = getProperties().getProperty("hibernate.connection.password"); + + try + { + Connection connection = DriverManager.getConnection(connectionURL, userName, passWord); + if (connection == null) + { + throw new DBException("No connection from driver manager: " + connectionURL); //$NON-NLS-1$ + } + + String autoCommit = getProperties().getProperty("hibernate.connection.autocommit"); + if (autoCommit != null) + { + connection.setAutoCommit(Boolean.valueOf(autoCommit)); + } + + return connection; + } + catch (SQLException ex) + { + throw new DBException(ex); + } + } + @Override public HibernateStoreAccessor createReader(ISession session) { diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/SessionManager.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/SessionManager.java index d2161158e8..2f87117f99 100644 --- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/SessionManager.java +++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/SessionManager.java @@ -25,6 +25,7 @@ import org.eclipse.emf.cdo.spi.server.InternalRepository; import org.eclipse.emf.cdo.spi.server.InternalSession; import org.eclipse.emf.cdo.spi.server.InternalSessionManager; +import org.eclipse.net4j.util.ReflectUtil.ExcludeFromDump; import org.eclipse.net4j.util.container.Container; import org.eclipse.net4j.util.lifecycle.LifecycleUtil; import org.eclipse.net4j.util.om.trace.ContextTracer; @@ -51,10 +52,13 @@ public class SessionManager extends Container<ISession> implements InternalSessi private InternalRepository repository; + @ExcludeFromDump private String encryptionAlgorithmName = SecurityUtil.PBE_WITH_MD5_AND_DES; + @ExcludeFromDump private byte[] encryptionSaltBytes = SecurityUtil.DEFAULT_SALT; + @ExcludeFromDump private int encryptionIterationCount = SecurityUtil.DEFAULT_ITERATION_COUNT; private int tokenLength = DEFAULT_TOKEN_LENGTH; diff --git a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/Net4jDBTest.java b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/Net4jDBTest.java index 635bf5e6f3..f74d9c5065 100644 --- a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/Net4jDBTest.java +++ b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/Net4jDBTest.java @@ -442,13 +442,13 @@ public class Net4jDBTest extends AbstractCDOTest Class<?> componentType = type.getComponentType(); if (componentType == byte.class) { - assertEquals("Error with type " + column.getElement1(), true, Arrays.equals((byte[])column.getElement2(), - (byte[])actual)); + assertEquals("Error with type " + column.getElement1(), true, + Arrays.equals((byte[])column.getElement2(), (byte[])actual)); } else if (componentType == char.class) { - assertEquals("Error with type " + column.getElement1(), true, Arrays.equals((char[])column.getElement2(), - (char[])actual)); + assertEquals("Error with type " + column.getElement1(), true, + Arrays.equals((char[])column.getElement2(), (char[])actual)); } else { @@ -465,7 +465,7 @@ public class Net4jDBTest extends AbstractCDOTest private void doTest(String tableName) throws Exception { store = (DBStore)getRepository().getStore(); - connection = store.getDBConnectionProvider().getConnection(); + connection = store.getConnection(); prepareTable(tableName); writeValues(tableName); diff --git a/plugins/org.eclipse.emf.cdo.tests.hibernate/META-INF/MANIFEST.MF b/plugins/org.eclipse.emf.cdo.tests.hibernate/META-INF/MANIFEST.MF index c3007ae3c8..c33456e989 100644 --- a/plugins/org.eclipse.emf.cdo.tests.hibernate/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.emf.cdo.tests.hibernate/META-INF/MANIFEST.MF @@ -14,6 +14,7 @@ Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.4.0,4.0.0)", org.eclipse.emf.cdo;bundle-version="[3.0.0,4.0.0)", org.eclipse.emf.cdo.server;bundle-version="[3.0.0,4.0.0)", org.eclipse.emf.cdo.server.hibernate;bundle-version="[3.0.0,4.0.0)", + org.eclipse.emf.cdo.server.db;bundle-version="[3.0.0,4.0.0)", org.eclipse.emf.cdo.tests;bundle-version="[3.0.0,4.0.0)", org.eclipse.emf.cdo.server.hibernate.teneo;bundle-version="[3.0.0,4.0.0)", org.hsqldb;bundle-version="[1.8.0,2.0.0)", diff --git a/plugins/org.eclipse.emf.cdo.tests.hibernate/src/app.properties b/plugins/org.eclipse.emf.cdo.tests.hibernate/src/app.properties index 5a6c7d2c38..27dd2993c4 100644 --- a/plugins/org.eclipse.emf.cdo.tests.hibernate/src/app.properties +++ b/plugins/org.eclipse.emf.cdo.tests.hibernate/src/app.properties @@ -5,6 +5,11 @@ hibernate.connection.pool_size=10 # ----------------------------------------------------------- # DEFAULT SETTINGS FOR IN MEMORY HSQLDB DATABASE. # + +#hibernate.dialect=org.hibernate.dialect.H2Dialect +#hibernate.connection.driver_class=org.h2.Driver +#hibernate.connection.url=jdbc:h2:_database/repo1 + hibernate.dialect=org.hibernate.dialect.HSQLDialect hibernate.connection.driver_class=org.hsqldb.jdbcDriver hibernate.connection.url=jdbc:hsqldb:mem:cdohibernate @@ -15,11 +20,11 @@ hibernate.cache.provider_class=org.hibernate.cache.HashtableCacheProvider #-------------------------------------------------------------- # EXAMPLE SETTING FOR MYSQL DATABASE. UNCOMMENT AND EDIT TO USE. -# +# #hibernate.connection.driver_class=com.mysql.jdbc.Driver #hibernate.connection.url=jdbc:mysql://localhost:3306/cdohibernate #hibernate.connection.username=root #hibernate.connection.password=root #hibernate.dialect=org.hibernate.dialect.MySQLInnoDBDialect -teneo.mapping.cascade_policy_on_non_containment = PERSIST,MERGE +teneo.mapping.cascade_policy_on_non_containment=PERSIST,MERGE diff --git a/plugins/org.eclipse.emf.cdo.tests.hibernate/src/org/eclipse/emf/cdo/tests/hibernate/HibernateConfig.java b/plugins/org.eclipse.emf.cdo.tests.hibernate/src/org/eclipse/emf/cdo/tests/hibernate/HibernateConfig.java index 3073238e47..2b48ea7953 100644 --- a/plugins/org.eclipse.emf.cdo.tests.hibernate/src/org/eclipse/emf/cdo/tests/hibernate/HibernateConfig.java +++ b/plugins/org.eclipse.emf.cdo.tests.hibernate/src/org/eclipse/emf/cdo/tests/hibernate/HibernateConfig.java @@ -10,8 +10,9 @@ */ package org.eclipse.emf.cdo.tests.hibernate; -import org.eclipse.emf.cdo.server.IStore; import org.eclipse.emf.cdo.server.IRepository.Props; +import org.eclipse.emf.cdo.server.IStore; +import org.eclipse.emf.cdo.server.db.CDODBBrowser; import org.eclipse.emf.cdo.server.hibernate.CDOHibernateUtil; import org.eclipse.emf.cdo.server.hibernate.IHibernateMappingProvider; import org.eclipse.emf.cdo.server.hibernate.teneo.TeneoUtil; @@ -36,6 +37,8 @@ public class HibernateConfig extends RepositoryConfig private Map<String, String> additionalProperties = new HashMap<String, String>(); + private transient CDODBBrowser dbBrowser; + public HibernateConfig() { super("Hibernate"); @@ -46,11 +49,13 @@ public class HibernateConfig extends RepositoryConfig { super.initRepositoryProperties(props); props.put(Props.SUPPORTING_AUDITS, "false"); + props.put(Props.SUPPORTING_BRANCHES, "false"); try { final Properties teneoProperties = new Properties(); - teneoProperties.putAll(getAdditionalProperties()); + Map<String, String> additionalProperties = getAdditionalProperties(); + teneoProperties.putAll(additionalProperties); teneoProperties.load(getClass().getResourceAsStream("/app.properties")); for (Object key : teneoProperties.keySet()) { @@ -75,4 +80,19 @@ public class HibernateConfig extends RepositoryConfig { return additionalProperties; } + + @Override + public void setUp() throws Exception + { + super.setUp(); + dbBrowser = new CDODBBrowser(repositories); + dbBrowser.activate(); + } + + @Override + public void tearDown() throws Exception + { + dbBrowser.deactivate(); + super.tearDown(); + } } diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/ConfigTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/ConfigTest.java index 627dc0daa1..68d1054ce0 100644 --- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/ConfigTest.java +++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/ConfigTest.java @@ -489,8 +489,16 @@ public abstract class ConfigTest extends AbstractOMTest implements IConstants protected IScenario getDefaultScenario() { - IScenario scenario = Scenario.load(); - if (scenario == null) + IScenario scenario; + try + { + scenario = Scenario.load(); + if (scenario == null) + { + scenario = Scenario.getDefault(); + } + } + catch (Exception ex) { scenario = Scenario.getDefault(); } diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/Scenario.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/Scenario.java index cdf08f5697..cc669113e4 100644 --- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/Scenario.java +++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/Scenario.java @@ -284,7 +284,7 @@ public class Scenario implements IScenario private Default() { setContainerConfig(ContainerConfig.Combined.INSTANCE); - setRepositoryConfig(RepositoryConfig.MEM.INSTANCE); + setRepositoryConfig(RepositoryConfig.MEMBranches.INSTANCE); setSessionConfig(SessionConfig.TCP.INSTANCE); setModelConfig(ModelConfig.Native.INSTANCE); } diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/DBUtil.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/DBUtil.java index ef59912763..4d2039966b 100644 --- a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/DBUtil.java +++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/DBUtil.java @@ -238,6 +238,51 @@ public final class DBUtil return null; } + /** + * @since 3.0 + */ + public static List<String> getAllSchemaTableNames(Connection connection) + { + try + { + DatabaseMetaData metaData = connection.getMetaData(); + return getAllSchemaTableNames(metaData); + } + catch (SQLException ex) + { + throw new DBException(ex); + } + } + + /** + * @since 3.0 + */ + public static List<String> getAllSchemaTableNames(DatabaseMetaData metaData) + { + ResultSet schemas = null; + + try + { + List<String> names = new ArrayList<String>(); + schemas = metaData.getSchemas(); + while (schemas.next()) + { + String name = schemas.getString(1); + names.add(name); + } + + return names; + } + catch (SQLException ex) + { + throw new DBException(ex); + } + finally + { + close(schemas); + } + } + public static List<String> getAllTableNames(Connection connection, String dbName) { ResultSet tables = null; @@ -246,10 +291,21 @@ public final class DBUtil { List<String> names = new ArrayList<String>(); DatabaseMetaData metaData = connection.getMetaData(); - tables = metaData.getTables(null, dbName.toUpperCase(), null, new String[] { "TABLE" }); //$NON-NLS-1$ + if (dbName != null) + { + dbName = dbName.toUpperCase(); + List<String> schemaNames = getAllSchemaTableNames(metaData); + if (!schemaNames.contains(dbName)) + { + dbName = null; + } + } + + tables = metaData.getTables(null, dbName, null, new String[] { "TABLE" }); //$NON-NLS-1$ while (tables.next()) { String name = tables.getString(3); + System.out.println(tables.getString(2) + "." + name); names.add(name); } |