Search in sources :

Example 1 with Command

use of com.wplatform.ddal.command.Command in project jdbc-shards by wplatform.

the class Function method cancelStatement.

private static boolean cancelStatement(Session session, int targetSessionId) {
    session.getUser().checkAdmin();
    Session[] sessions = session.getDatabase().getSessions();
    for (Session s : sessions) {
        if (s.getId() == targetSessionId) {
            Command c = s.getCurrentCommand();
            if (c == null) {
                return false;
            }
            c.cancel();
            return true;
        }
    }
    return false;
}
Also used : Command(com.wplatform.ddal.command.Command) Session(com.wplatform.ddal.engine.Session)

Example 2 with Command

use of com.wplatform.ddal.command.Command in project jdbc-shards by wplatform.

the class Session method prepareLocal.

/**
 * Parse and prepare the given SQL statement. This method also checks if the
 * connection has been closed.
 *
 * @param sql the SQL statement
 * @return the prepared statement
 */
public Command prepareLocal(String sql) {
    if (closed) {
        throw DbException.get(ErrorCode.CONNECTION_BROKEN_1, "session closed");
    }
    Command command;
    if (queryCacheSize > 0) {
        if (queryCache == null) {
            queryCache = SmallLRUCache.newInstance(queryCacheSize);
        // modificationMetaID = database.getModificationMetaId();
        } else {
            // ignore table structure modification
            /*
                 * long newModificationMetaID =
                 * database.getModificationMetaId(); if (newModificationMetaID
                 * != modificationMetaID) { queryCache.clear();
                 * modificationMetaID = newModificationMetaID; }
                 */
            command = queryCache.get(sql);
            if (command != null && command.canReuse()) {
                command.reuse();
                return command;
            }
        }
    }
    Parser parser = new Parser(this);
    command = parser.prepareCommand(sql);
    if (queryCache != null) {
        if (command.isCacheable()) {
            queryCache.put(sql, command);
        }
    }
    return command;
}
Also used : Command(com.wplatform.ddal.command.Command) Parser(com.wplatform.ddal.command.Parser)

Aggregations

Command (com.wplatform.ddal.command.Command)2 Parser (com.wplatform.ddal.command.Parser)1 Session (com.wplatform.ddal.engine.Session)1