Search in sources :

Example 1 with SessionRemote

use of org.h2.engine.SessionRemote in project h2database by h2database.

the class CommandRemote method prepare.

private void prepare(SessionRemote s, boolean createParams) {
    id = s.getNextId();
    for (int i = 0, count = 0; i < transferList.size(); i++) {
        try {
            Transfer transfer = transferList.get(i);
            boolean v16 = s.getClientVersion() >= Constants.TCP_PROTOCOL_VERSION_16;
            if (createParams) {
                s.traceOperation(v16 ? "SESSION_PREPARE_READ_PARAMS2" : "SESSION_PREPARE_READ_PARAMS", id);
                transfer.writeInt(v16 ? SessionRemote.SESSION_PREPARE_READ_PARAMS2 : SessionRemote.SESSION_PREPARE_READ_PARAMS).writeInt(id).writeString(sql);
            } else {
                s.traceOperation("SESSION_PREPARE", id);
                transfer.writeInt(SessionRemote.SESSION_PREPARE).writeInt(id).writeString(sql);
            }
            s.done(transfer);
            isQuery = transfer.readBoolean();
            readonly = transfer.readBoolean();
            cmdType = v16 && createParams ? transfer.readInt() : UNKNOWN;
            int paramCount = transfer.readInt();
            if (createParams) {
                parameters.clear();
                for (int j = 0; j < paramCount; j++) {
                    ParameterRemote p = new ParameterRemote(j);
                    p.readMetaData(transfer);
                    parameters.add(p);
                }
            }
        } catch (IOException e) {
            s.removeServer(e, i--, ++count);
        }
    }
}
Also used : ParameterRemote(org.h2.expression.ParameterRemote) Transfer(org.h2.value.Transfer) IOException(java.io.IOException)

Example 2 with SessionRemote

use of org.h2.engine.SessionRemote in project h2database by h2database.

the class JdbcDatabaseMetaData method hasSynonyms.

private boolean hasSynonyms() {
    Boolean hasSynonyms = this.hasSynonyms;
    if (hasSynonyms == null) {
        SessionInterface si = conn.getSession();
        if (si instanceof SessionRemote) {
            SessionRemote sr = (SessionRemote) si;
            int clientVersion = sr.getClientVersion();
            if (clientVersion >= Constants.TCP_PROTOCOL_VERSION_17) {
                hasSynonyms = true;
            } else if (clientVersion <= Constants.TCP_PROTOCOL_VERSION_15) {
                hasSynonyms = false;
            } else {
                // 1.4.194-1.4.196
                CommandInterface c = sr.prepareCommand("CALL H2VERSION()", Integer.MAX_VALUE);
                ResultInterface result = c.executeQuery(0, false);
                result.next();
                String s = result.currentRow()[0].getString();
                result.close();
                hasSynonyms = "1.4.196".equals(s);
            }
        } else {
            hasSynonyms = true;
        }
        this.hasSynonyms = hasSynonyms;
    }
    return hasSynonyms;
}
Also used : SessionRemote(org.h2.engine.SessionRemote) ResultInterface(org.h2.result.ResultInterface) SessionInterface(org.h2.engine.SessionInterface) CommandInterface(org.h2.command.CommandInterface)

Aggregations

IOException (java.io.IOException)1 CommandInterface (org.h2.command.CommandInterface)1 SessionInterface (org.h2.engine.SessionInterface)1 SessionRemote (org.h2.engine.SessionRemote)1 ParameterRemote (org.h2.expression.ParameterRemote)1 ResultInterface (org.h2.result.ResultInterface)1 Transfer (org.h2.value.Transfer)1