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) {
LOG.info("No user specified; will attempt to login with no credentials");
} else {
if (password == null) {
throw new SqlObjectStoreException("No password specified for database connection");
}
}
Class.forName(driver);
connection = 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);
}
}