public static void closeDatabaseEngine() throws SQLException {
        try {
            dbProperties.put("shutdown", "true");
            DriverManager.getConnection(dbProperties.getProperty("derby.url"), 
                    dbProperties);
        } catch (SQLException ex) {
			dbProperties.remove("shutdown");
			// At database engine shutdown, Derby throws error 50.000 and SQLState XJ015 to show 
			// that the operation was successful.
			int errorCode = ex.getErrorCode();
			if (!(errorCode == 50000 && "XJ015".equals(ex.getSQLState()))) {
				throw ex;
			}
			log.info("Successfully disconnected from the database engine: {}", errorCode);
        } 
    }