Package railo.runtime.exp

Examples of railo.runtime.exp.DatabaseException


      }
    }

  // Group By 
  if(select.getGroupbys().length>0)
    throw new DatabaseException("group by are not supported at the moment",null,sql,null);
  if(select.getHaving()!=null)
    throw new DatabaseException("having is not supported at the moment",null,sql,null);
   
  }
View Full Code Here


    //print.e("name:"+exp.getClass().getName());
    if(exp instanceof Value) return ((Value)exp).getValue();//executeConstant(sql,qr, (Value)exp, row);
    if(exp instanceof Column) return executeColumn(sql,qr, (Column)exp, row);
    if(exp instanceof Operation) return executeOperation(pc,sql,qr, (Operation)exp, row);
    if(exp instanceof BracketExpression) return executeBracked(pc,sql,qr, (BracketExpression)exp, row);
    throw new DatabaseException("unsupported sql statement ["+exp+"]",null,sql,null);
  }
View Full Code Here

    //print.o(exp.getClass().getName());
    if(exp instanceof Value) return ((Value)exp).getValue();//executeConstant(sql,qr, (Value)exp, row);
    if(exp instanceof Column) return executeColumn(sql,qr, (Column)exp, row,columnDefault);
    if(exp instanceof Operation) return executeOperation(pc,sql,qr, (Operation)exp, row);
    if(exp instanceof BracketExpression) return executeBracked(pc,sql,qr, (BracketExpression)exp, row);
    throw new DatabaseException("unsupported sql statement ["+exp+"]",null,sql,null);
  }
View Full Code Here

      int o = op3.getOperator();
      if(o==Operation.OPERATION3_BETWEEN) return executeBetween(pc,sql,qr,op3,row);
      if(o==Operation.OPERATION3_LIKE) return executeLike(pc,sql,qr,op3,row);
    }
   
    if(!(operation instanceof OperationN)) throw new DatabaseException("invalid syntax for SQL Statement",null,sql,null);
   
    OperationN opn=(OperationN) operation;
   
    String op=StringUtil.toLowerCase(opn.getOperator());
    Expression[] operators = opn.getOperants();
   
    /*if(count==0 && op.equals("?")) {
        int pos=sql.getPosition();
        if(sql.getItems().length<=pos) throw new DatabaseException("invalid syntax for SQL Statement",null,sql);
        sql.setPosition(pos+1);
        return sql.getItems()[pos].getValueForCF();
    }*/
        // 11111111111111111111111111111111111111111111111111111
        if(operators.length==1) {
            Object value = executeExp( pc,sql,qr,operators[0],row);
           
            // Functions
            switch(op.charAt(0)) {
            case 'a':
                if(op.equals("abs"))    return new Double(MathUtil.abs(Caster.toDoubleValue(value)));
                if(op.equals("acos"))   return new Double(Math.acos(Caster.toDoubleValue(value)));
                if(op.equals("asin"))   return new Double(Math.asin(Caster.toDoubleValue(value)));
                if(op.equals("atan"))   return new Double(Math.atan(Caster.toDoubleValue(value)));
            break;
            case 'c':
                if(op.equals("ceiling"))return new Double(Math.ceil(Caster.toDoubleValue(value)));
                if(op.equals("cos"))    return new Double(Math.cos(Caster.toDoubleValue(value)));
                if(op.equals("cast"))    return Caster.castTo(pc, CFTypes.toShort(operators[0].getAlias(),true,CFTypes.TYPE_UNKNOW),operators[0].getAlias(), value);
            break;
            case 'e':
                if(op.equals("exp"))    return new Double(Math.exp(Caster.toDoubleValue(value)));
            break;
            case 'f':
                if(op.equals("floor"))  return new Double(Math.floor(Caster.toDoubleValue(value)));
            break;
            case 'u':
                if(op.equals("upper") || op.equals("ucase")) return Caster.toString(value).toUpperCase();
            break;
           
            case 'l':
                if(op.equals("lower")|| op.equals("lcase")) return Caster.toString(value).toLowerCase();
                if(op.equals("ltrim"))  return StringUtil.ltrim(Caster.toString(value),null);
                if(op.equals("length")) return new Double(Caster.toString(value).length());
            break;
            case 'r':
                if(op.equals("rtrim"))  return StringUtil.rtrim(Caster.toString(value),null);
            break;
            case 's':
                if(op.equals("sign"))   return new Double(MathUtil.sgn(Caster.toDoubleValue(value)));
                if(op.equals("sin"))    return new Double(Math.sin(Caster.toDoubleValue(value)));
                if(op.equals("soundex"))return StringUtil.soundex(Caster.toString(value));
                if(op.equals("sin"))    return new Double(Math.sqrt(Caster.toDoubleValue(value)));
            break;
            case 't':
                if(op.equals("tan"))    return new Double(Math.tan(Caster.toDoubleValue(value)));
                if(op.equals("trim"))   return Caster.toString(value).trim();
            break;
            }
           
        }
       
        // 22222222222222222222222222222222222222222222222222222
    else if(operators.length==2) {
     
      //if(op.equals("=") || op.equals("in")) return executeEQ(pc,sql,qr,expression,row);
     
            Object left = executeExp(pc,sql,qr,operators[0],row);
            Object right = executeExp(pc,sql,qr,operators[1],row);
           
      // Functions
            switch(op.charAt(0)) {
            case 'a':
                if(op.equals("atan2"))
                    return new Double(Math.atan2(Caster.toDoubleValue(left),Caster.toDoubleValue(right)));
            break;
            case 'b':
                if(op.equals("bitand"))
                    return new Double(Operator.bitand(Caster.toDoubleValue(left),Caster.toDoubleValue(right)));
                if(op.equals("bitor"))
                    return new Double(Operator.bitor(Caster.toDoubleValue(left),Caster.toDoubleValue(right)));
            break;
            case 'c':
                if(op.equals("concat"))
                    return Caster.toString(left).concat(Caster.toString(right));
            break;
            case 'm':
                if(op.equals("mod"))
                    return new Double(Operator.modulus(Caster.toDoubleValue(left),Caster.toDoubleValue(right)));
            break;
            }
               
      //throw new DatabaseException("unsopprted sql statement ["+op+"]",null,sql);
    }
        // 3333333333333333333333333333333333333333333333333333333333333333333
   
        if(op.equals("in")) return executeIn(pc,sql,qr,opn,row,false);
        if(op.equals("not_in")) return executeIn(pc,sql,qr,opn,row,true);
   
       
        /*
       
        addCustomFunction("cot",1);
        addCustomFunction("degrees",1);
        addCustomFunction("log",1);
        addCustomFunction("log10",1);

        addCustomFunction("pi",0);
        addCustomFunction("power",2);
        addCustomFunction("radians",1);
        addCustomFunction("rand",0);
        addCustomFunction("round",2);
        addCustomFunction("roundmagic",1);
        addCustomFunction("truncate",2);
        addCustomFunction("ascii",1);
        addCustomFunction("bit_length",1);
        addCustomFunction("char",1);
        addCustomFunction("char_length",1);
        addCustomFunction("difference",2);
        addCustomFunction("hextoraw",1);
        addCustomFunction("insert",4);
        addCustomFunction("left",2);
        addCustomFunction("locate",3);
        addCustomFunction("octet_length",1);
        addCustomFunction("rawtohex",1);
        addCustomFunction("repeat",2);
        addCustomFunction("replace",3);
        addCustomFunction("right",2);
        addCustomFunction("space",1);
        addCustomFunction("substr",3);
        addCustomFunction("substring",3);
        addCustomFunction("curdate",0);
        addCustomFunction("curtime",0);
        addCustomFunction("datediff",3);
        addCustomFunction("dayname",1);
        addCustomFunction("dayofmonth",1);
        addCustomFunction("dayofweek",1);
        addCustomFunction("dayofyear",1);
        addCustomFunction("hour",1);
        addCustomFunction("minute",1);
        addCustomFunction("month",1);
        addCustomFunction("monthname",1);
        addCustomFunction("now",0);
        addCustomFunction("quarter",1);
        addCustomFunction("second",1);
        addCustomFunction("week",1);
        addCustomFunction("year",1);
        addCustomFunction("current_date",1);
        addCustomFunction("current_time",1);
        addCustomFunction("current_timestamp",1);
        addCustomFunction("database",0);
        addCustomFunction("user",0);
        addCustomFunction("current_user",0);
        addCustomFunction("identity",0);
        addCustomFunction("ifnull",2);
        addCustomFunction("casewhen",3);
        addCustomFunction("convert",2);
        //addCustomFunction("cast",1);
        addCustomFunction("coalesce",1000);
        addCustomFunction("nullif",2);
        addCustomFunction("extract",1);
        addCustomFunction("position",1);
        */
       
    //print(expression);
    throw new DatabaseException(
        "unsopprted sql statement ("+op+") ",null,sql,null);

  }
View Full Code Here

   * @throws PageException
   */
  private Object executeColumn(SQL sql, Query qr, Column column, int row) throws PageException {
    if(column.getColumn().equals("?")) {
        int pos=column.getColumnIndex();
        if(sql.getItems().length<=pos) throw new DatabaseException("invalid syntax for SQL Statement",null,sql,null);
        return sql.getItems()[pos].getValueForCF();
    }
    return column.getValue(qr, row);
    //return qr.getAt(column.getColumn(),row); 
  }
View Full Code Here

  }
 
  private Object executeColumn(SQL sql,Query qr, Column column, int row, Object defaultValue) throws PageException {
      if(column.getColumn().equals("?")) {
        int pos=column.getColumnIndex();
        if(sql.getItems().length<=pos) throw new DatabaseException("invalid syntax for SQL Statement",null,sql,null);
        return sql.getItems()[pos].getValueForCF();
    }
    return column.getValue(qr, row,defaultValue)
  }
View Full Code Here

          throw new ApplicationException("there is no DatasourceResource driver for this database ["+data.getPrefix()+"]");
       
        cores.put(data.datasourceName, core);
      }
      catch(SQLException e) {
        throw new DatabaseException(e,dc);
      }
        finally {
          release(dc);
          //manager.releaseConnection(CONNECTION_ID,dc);
        }
View Full Code Here

    try {
      dc.getConnection().setAutoCommit(autoCommit);
      dc.getConnection().setTransactionIsolation(Connection.TRANSACTION_READ_UNCOMMITTED);
    }
    catch (SQLException e) {
      throw new DatabaseException(e,dc);
    }
   
    return dc;
  }
View Full Code Here

        dc = getDatasourceConnection(data)
        Attr attr=getCore(data).getAttr(dc,data.getPrefix(),fullPathHash,path,name);
        if(attr!=null)return putToCache(data,path,name, attr);
      }
      catch (SQLException e) {
        throw new DatabaseException(e,dc);
      }
        finally {
          getManager().releaseConnection(ThreadLocalPageContext.get(),dc);
        }
    }
View Full Code Here

        //putToCache(data, path, rtn);
        return rtn;
      }
    }
    catch (SQLException e) {
      throw new DatabaseException(e,dc);
    }
      finally {
        release(dc);
        //manager.releaseConnection(CONNECTION_ID,dc);
      }
View Full Code Here

TOP

Related Classes of railo.runtime.exp.DatabaseException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.