Package railo.runtime.exp

Examples of railo.runtime.exp.DatabaseException


      else if(type==TYPE_VERSION)    typeVersion(dc.getConnection().getMetaData());
      else if(type==TYPE_USERS)    typeUsers(dc.getConnection().getMetaData());
     
    }
    catch(SQLException sqle) {
      throw new DatabaseException(sqle,dc);
    }
    finally {
      manager.releaseConnection(pageContext,dc);
    }
   
View Full Code Here


    private String[] getPrimaryKeys(DatasourceConnection dc) throws PageException {
      railo.runtime.type.Query query = getPrimaryKeysAsQuery(dc);
    int recCount=query.getRecordcount();
        String[] pKeys=new String[recCount];
   
        if(recCount==0) throw new DatabaseException("can't find primary keys of table ["+tablename+"]",null,null,dc);
       
        for(int row=1;row<=recCount;row++) {
            pKeys[row-1]=Caster.toString(query.getAt("column_name",row));
        }
View Full Code Here

        DatabaseMetaData meta;
        try {
            meta = dc.getConnection().getMetaData();
        }
        catch (SQLException e) {
            throw new DatabaseException(e,dc);
        }
       
        try {
            return new QueryImpl(meta.getPrimaryKeys(tablequalifier, tableowner, tablename),-1,"query",pageContext.getTimeZone());
        }
    catch (SQLException e) {
        try {
            return new QueryImpl(meta.getBestRowIdentifier(tablequalifier, tableowner, tablename, 0, false),-1,"query",pageContext.getTimeZone());
            }
        catch (SQLException sqle) {
                throw new DatabaseException("can't find primary keys of table ["+tablename+"] ("+ExceptionUtil.getMessage(sqle)+")",null,null,dc);
            }
        }
    }
View Full Code Here

                }
            }
        }
        if((setItems.size()+whereItems.size())==0) return null;
       
        if(whereItems.size()==0)throw new DatabaseException("can't find primary keys ["+ListUtil.arrayToList(keys,",")+"] of table ["+tablename+"] in form scope",null,null,dc);
       
        StringBuffer sql=new StringBuffer();
        sql.append("update ");
        if(tablequalifier!=null && tablequalifier.length()>0) {
            sql.append(tablequalifier);
View Full Code Here

  public int doEndTag() throws PageException  {   
    if(hasChangedPSQ)pageContext.setPsq(orgPSQ);
    String strSQL=bodyContent.getString();
    // no SQL String defined
    if(strSQL.length()==0)
      throw new DatabaseException("no sql string defined, inside query tag",null,null,null);
    // cannot use attribute params and queryparam tag
    if(items.size()>0 && params!=null)
      throw new DatabaseException("you cannot use the attribute params and sub tags queryparam at the same time",null,null,null);
    // create SQL
    SQL sql;
    if(params!=null) {
      if(Decision.isArray(params))
        sql=QueryParamConverter.convert(strSQL, Caster.toArray(params));
      else if(Decision.isStruct(params))
        sql=QueryParamConverter.convert(strSQL, Caster.toStruct(params));
      else
        throw new DatabaseException("value of the attribute [params] has to be a struct or a array",null,null,null);
    }
    else sql=items.size()>0?new SQLImpl(strSQL,items.toArray(new SQLItem[items.size()])):new SQLImpl(strSQL);
   
    railo.runtime.type.Query query=null;
    long exe=0;
View Full Code Here

        if(vf.getValue() instanceof Array) {
          names[count]=vf.getNameAsString();
          columns[count]=(Array) vf.getValue();
          count++;
        }
        else throw new DatabaseException("invalid argument for function query, only array as value are allowed","example: query(column1:array(1,2,3))",null,null);
      }
      else throw new DatabaseException("invalid argument for function query, only named argument are allowed","example: query(column1:array(1,2,3))",null,null);
    }
    Query query=new QueryImpl(names,columns,"query");
    return query;
  }
View Full Code Here

      if(Decision.isArray(params))
        sql=QueryParamConverter.convert(strSQL, Caster.toArray(params));
      else if(Decision.isStruct(params))
        sql=QueryParamConverter.convert(strSQL, Caster.toStruct(params));
      else
        throw new DatabaseException("value of the argument [params] has to be a struct or a array",null,null,null);
     
      //new QueryImpl(pc,)
    }
    return null;
    }
View Full Code Here

    int[] dirs = new int[arrColumnNames.length];
   
    // directions
    if(!StringUtil.isEmpty(directions)) {
      String[] arrDirections = ListUtil.trimItems(ListUtil.listToStringArray(directions, ','));
      if(arrColumnNames.length!=arrDirections.length)throw new DatabaseException("column names and directions has not the same count",null,null,null);
     
      String direction;
      for(int i=0;i<dirs.length;i++){
        direction=arrDirections[i].toLowerCase();
        dirs[i]=0;
        if(direction.equals("asc"))dirs[i]=Query.ORDER_ASC;
        else if(direction.equals("desc"))dirs[i]=Query.ORDER_DESC;
        else {   
          throw new DatabaseException("argument direction of function querySort must be \"asc\" or \"desc\", now \""+direction+"\"",null,null,null);
        }
      }
    }
    else {
      for(int i=0;i<dirs.length;i++){
View Full Code Here

      Pattern pattern=(Pattern) patterns.get(wildcard+escape);
        if(pattern!=null) return pattern;
        char esc=0;
        if(!StringUtil.isEmpty(escape)){
          esc=escape.charAt(0);
          if(escape.length()>1)throw new DatabaseException("Invalid escape character ["+escape+"] has been specified in a LIKE conditional",null,sql,null);
        }
       
      StringBuffer sb = new StringBuffer(wildcard.length());
        int len=wildcard.length();
        //boolean isEscape=false;
        char c;
        for(int i=0;i<len;i++) {
            c = wildcard.charAt(i);
            if(c == esc){
              if(i+1==len)throw new DatabaseException("Invalid Escape Sequence. Valid sequence pairs for this escape character are: ["+esc+"%] or ["+esc+"_]",null,sql,null);
              c = wildcard.charAt(++i);
              if(c == '%')sb.append(c);
              else if(c == '_') sb.append(c);
              else throw new DatabaseException("Invalid Escape Sequence ["+esc+""+c+"]. Valid sequence pairs for this escape character are: ["+esc+"%] or ["+esc+"_]",null,sql,null);
            }
            else {
              if(c == '%')sb.append(".*");
                else if(c == '_') sb.append('.');
                else if(specials.indexOf(c)!=-1)sb.append('\\').append(c);
View Full Code Here

      }
      else
        return value;
      }
      catch(SQLException e) {
        throw new DatabaseException(e,null);
      }
      catch(Throwable t) {
        throw Caster.toPageException(t);
      }
    }
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.