commandlist.java

来自「非常棒的java数据库」· Java 代码 · 共 71 行

JAVA
71
字号
/*
 * Copyright 2004-2008 H2 Group. Licensed under the H2 License, Version 1.0
 * (http://h2database.com/html/license.html).
 * Initial Developer: H2 Group
 */
package org.h2.command;

import java.sql.SQLException;

import org.h2.result.LocalResult;
import org.h2.util.ObjectArray;

/**
 * Represents a list of SQL statements.
 */
public class CommandList extends Command {

    private final Command command;
    private final String remaining;

    // TODO lock if possible!

    public CommandList(Parser parser, String sql, Command c, String remaining) {
        super(parser, sql);
        this.command = c;
        this.remaining = remaining;
    }

    public ObjectArray getParameters() {
        return command.getParameters();
    }

    private void executeRemaining() throws SQLException {
        Command command = session.prepareLocal(remaining);
        if (command.isQuery()) {
            command.query(0);
        } else {
            command.update();
        }
    }

    public int update() throws SQLException {
        int updateCount = command.executeUpdate();
        executeRemaining();
        return updateCount;
    }

    public LocalResult query(int maxrows) throws SQLException {
        LocalResult result = command.query(maxrows);
        executeRemaining();
        return result;
    }

    public boolean isQuery() {
        return command.isQuery();
    }

    public boolean isTransactional() {
        return true;
    }

    public boolean isReadOnly() {
        return false;
    }

    public LocalResult queryMeta() throws SQLException {
        return command.queryMeta();
    }

}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?