Exemple #1
0
 /**
  * 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;
 }
Exemple #2
0
 /**
  * Parse and prepare the given SQL statement.
  *
  * @param sql the SQL statement
  * @param rightsChecked true if the rights have already been checked
  * @return the prepared statement
  */
 public Prepared prepare(String sql, boolean rightsChecked) {
   Parser parser = new Parser(this);
   parser.setRightsChecked(rightsChecked);
   return parser.prepare(sql);
 }