final String url = params.getString(BASE + "connection");
final String user = params.getString(BASE + "user");
final String password = params.getString(BASE + "password");
if (connection != null) {
throw new SqlObjectStoreException("Connection already established");
}
if (driver == null) {
throw new SqlObjectStoreException("No driver specified for database connection");
}
if (url == null) {
throw new SqlObjectStoreException("No connection URL specified to database");
}
if (user == null) {
throw new SqlObjectStoreException("No user specified for database connection");
}
if (password == null) {
throw new SqlObjectStoreException("No password specified for database connection");
}
Class.forName(driver);
LOG.info("Connecting to " + url + " as " + user);
connection = DriverManager.getConnection(url, user, password);
if (connection == null) {
throw new SqlObjectStoreException("No connection established to " + url);
}
} catch (final SQLException e) {
throw new SqlObjectStoreException("Failed to start", e);
} catch (final ClassNotFoundException e) {
throw new SqlObjectStoreException("Could not find database driver", e);
}
final String BASE_DATATYPE = baseName + ".datatypes.";
final IsisConfiguration dataTypes = IsisContext.getConfiguration().getProperties(BASE_DATATYPE);
populateSqlDataTypes(dataTypes, BASE_DATATYPE);