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;
}
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;
}