27 lines
727 B
Java
27 lines
727 B
Java
package de.vanitasvitae.fasel.db;
|
|
|
|
import java.sql.SQLException;
|
|
|
|
import com.j256.ormlite.support.ConnectionSource;
|
|
|
|
public class DatabaseService {
|
|
|
|
private static DatabaseCreator CREATOR;
|
|
|
|
public interface DatabaseCreator {
|
|
ConnectionSource getConnectionSource(String databaseName) throws SQLException;
|
|
}
|
|
|
|
public static ConnectionSource getConnectionSource(String databaseName) throws SQLException {
|
|
if (CREATOR == null) {
|
|
throw new IllegalStateException("No DatabaseCreator set in DatabaseService.");
|
|
}
|
|
|
|
return CREATOR.getConnectionSource(databaseName);
|
|
}
|
|
|
|
public static void setDatabaseCreator(DatabaseCreator creator) {
|
|
CREATOR = creator;
|
|
}
|
|
}
|