class ShutdownDatabase extends AdminStatement {

    private final Database db;
    private final boolean immediately;

    public ShutdownDatabase(ServerSession session, Database db, boolean immediately) {
        super(session);
        this.db = db;
        this.immediately = immediately;
    }

    @Override
    public int getType() {
        return SQLStatement.SHUTDOWN_DATABASE;
    }

    @Override
    public int update() {<FILL_FUNCTION_BODY>}
}

        LealoneDatabase.checkAdminRight(session, "shutdown database");
        // 如果是LealoneDatabase什么都不做
        if (LealoneDatabase.isMe(db.getName()))
            return 0;
        DbObjectLock lock = LealoneDatabase.getInstance().tryExclusiveDatabaseLock(session);
        if (lock == null)
            return -1;
        db.markClosed();
        if (immediately) {
            db.shutdownImmediately();
        } else if (db.getSessionCount() == 0) {
            db.closeIfNeeded();
        }
        return 0;
    
<methods>public void <init>(com.lealone.db.session.ServerSession) ,public boolean needRecompile() <variables>