/** * Get the singleton {@code H2EmbeddedDatabaseConfigurer} instance. * @return the configurer instance * @throws ClassNotFoundException if H2 is not on the classpath */ @SuppressWarnings("unchecked") public static synchronized H2EmbeddedDatabaseConfigurer getInstance() throws ClassNotFoundException { if (instance == null) { instance = new H2EmbeddedDatabaseConfigurer( (Class<? extends Driver>) ClassUtils.forName("org.h2.Driver", H2EmbeddedDatabaseConfigurer.class.getClassLoader())); } return instance; }
/** * Return a configurer instance for the given embedded database type. * @param type the embedded database type (HSQL, H2 or Derby) * @return the configurer instance * @throws IllegalStateException if the driver for the specified database type is not available */ public static EmbeddedDatabaseConfigurer getConfigurer(EmbeddedDatabaseType type) throws IllegalStateException { Assert.notNull(type, "EmbeddedDatabaseType is required"); try { switch (type) { case HSQL: return HsqlEmbeddedDatabaseConfigurer.getInstance(); case H2: return H2EmbeddedDatabaseConfigurer.getInstance(); case DERBY: return DerbyEmbeddedDatabaseConfigurer.getInstance(); default: throw new UnsupportedOperationException("Embedded database type [" + type + "] is not supported"); } } catch (ClassNotFoundException | NoClassDefFoundError ex) { throw new IllegalStateException("Driver for test database type [" + type + "] is not available", ex); } }
/** * Get the singleton {@link H2EmbeddedDatabaseConfigurer} instance. * @return the configurer * @throws ClassNotFoundException if H2 is not on the classpath */ @SuppressWarnings("unchecked") public static synchronized H2EmbeddedDatabaseConfigurer getInstance() throws ClassNotFoundException { if (INSTANCE == null) { INSTANCE = new H2EmbeddedDatabaseConfigurer( (Class<? extends Driver>) ClassUtils.forName("org.h2.Driver", H2EmbeddedDatabaseConfigurer.class.getClassLoader())); } return INSTANCE; }
public static EmbeddedDatabaseConfigurer getConfigurer(EmbeddedDatabaseType type) throws IllegalStateException { Assert.notNull(type, "EmbeddedDatabaseType is required"); try { switch (type) { case HSQL: return HsqlEmbeddedDatabaseConfigurer.getInstance(); case H2: return H2EmbeddedDatabaseConfigurer.getInstance(); case DERBY: return DerbyEmbeddedDatabaseConfigurer.getInstance(); default: throw new UnsupportedOperationException("Other embedded database types not yet supported"); } } catch (ClassNotFoundException ex) { throw new IllegalStateException("Driver for test database type [" + type + "] is not available in the classpath", ex); } }
/** * Get the singleton {@code H2EmbeddedDatabaseConfigurer} instance. * @return the configurer instance * @throws ClassNotFoundException if H2 is not on the classpath */ @SuppressWarnings("unchecked") public static synchronized H2EmbeddedDatabaseConfigurer getInstance() throws ClassNotFoundException { if (instance == null) { instance = new H2EmbeddedDatabaseConfigurer( (Class<? extends Driver>) ClassUtils.forName("org.h2.Driver", H2EmbeddedDatabaseConfigurer.class.getClassLoader())); } return instance; }