use of org.neo4j.dbms.api.DatabaseManagementException in project neo4j by neo4j.
the class DatabaseManagementServiceImpl method systemDatabaseExecute.
private void systemDatabaseExecute(String query, SystemDatabaseExecutionContext beforeCommitHook) {
try {
GraphDatabaseAPI database = (GraphDatabaseAPI) database(SYSTEM_DATABASE_NAME);
try (InternalTransaction transaction = database.beginTransaction(KernelTransaction.Type.EXPLICIT, LoginContext.AUTH_DISABLED)) {
transaction.execute(query);
beforeCommitHook.accept(database, transaction);
transaction.commit();
}
} catch (QueryExecutionException | KernelException e) {
throw new DatabaseManagementException(e);
}
}
use of org.neo4j.dbms.api.DatabaseManagementException in project neo4j by neo4j.
the class DefaultDatabaseManager method upgradeDatabase.
@Override
public synchronized void upgradeDatabase(NamedDatabaseId namedDatabaseId) throws DatabaseNotFoundException {
StandaloneDatabaseContext context = getDatabaseContext(namedDatabaseId).orElseThrow(() -> new DatabaseNotFoundException("Database not found: " + namedDatabaseId));
Database database = context.database();
log.info("Upgrading '%s'.", namedDatabaseId);
// Clear any failed state, e.g. due to format being too old on startup.
context.fail(null);
try {
database.upgrade(true);
} catch (Throwable throwable) {
String message = "Failed to upgrade " + namedDatabaseId;
context.fail(throwable);
throw new DatabaseManagementException(message, throwable);
}
}
Aggregations