예제 #1
0
 public synchronized Command prepareCommand(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);
     } else {
       command = queryCache.get(sql);
       if (command != null && command.canReuse()) {
         command.reuse();
         return command;
       }
     }
   }
   Parser parser = createParser();
   command = parser.prepareCommand(sql);
   if (queryCache != null) {
     if (command.isCacheable()) {
       queryCache.put(sql, command);
     }
   }
   return command;
 }
예제 #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 = createParser();
   parser.setRightsChecked(rightsChecked);
   return parser.prepare(sql);
 }