Package railo.runtime.db

Examples of railo.runtime.db.SQLItemImpl


    public void log(int level, String application, String message) {
      DatasourceConnection dc=null;
      try {
      dc = pool.getDatasourceConnection(ThreadLocalPageContext.get(),datasource, username, password);
      SQLImpl sql = new SQLImpl(INSERT);
      sql.addItems(new SQLItemImpl(application,CFTypes.VARCHAR));
      sql.addItems(new SQLItemImpl(message,CFTypes.VARCHAR));
      sql.addItems(new SQLItemImpl(new DateTimeImpl(),CFTypes.DATE));
      new QueryImpl(ThreadLocalPageContext.get(),dc,sql,-1,-1,-1,"query");
    }
      catch (PageException e) {
      console.log(level, application, message);
    }
View Full Code Here


  public static Struct toStruct(Object obj, Struct defaultValue) {
    return caster().toStruct(obj,defaultValue);
  }

  public static SQLItem toSQLItem(Object value, int type) {
    return new SQLItemImpl(value,type);
  }
View Full Code Here

  public Query select(Config config,String cfid,String applicationName,DatasourceConnection dc, int type,Log log, boolean createTableIfNotExist) throws PageException {
    String strType = VariableInterpreter.scopeInt2String(type);
    Query query=null;
      SQL sqlSelect=new SQLImpl("select data from "+PREFIX+"_"+strType+"_data where cfid=? and name=? and expires > ?"
        ,new SQLItem[]{
       new SQLItemImpl(cfid,Types.VARCHAR),
      new SQLItemImpl(applicationName,Types.VARCHAR),
      new SQLItemImpl(now(config),Types.VARCHAR)
    });
     
      PageContext pc = ThreadLocalPageContext.get();
   
    try {
View Full Code Here

 
  private static int _update(Config config,Connection conn,String cfid, String applicationName, String strSQL,Struct data, long timeSpan, Log log, TimeZone tz) throws SQLException, PageException {
    //String appName = pc.getApplicationContext().getName();
    try{
      SQLImpl sql = new SQLImpl(strSQL,new SQLItem[]{
        new SQLItemImpl(createExpires(config,timeSpan),Types.VARCHAR),
        new SQLItemImpl(new ScriptConverter().serializeStruct(data,ignoreSet),Types.VARCHAR),
        new SQLItemImpl(cfid,Types.VARCHAR),
        new SQLItemImpl(applicationName,Types.VARCHAR)
      });
      ScopeContext.info(log,sql.toString());
     
      return execute(conn, sql,tz);
    }
View Full Code Here

  @Override
  public void delete(Config config, String cfid, String applicationName, DatasourceConnection dc, int type, Log log) throws PageException, SQLException {
    String strType = VariableInterpreter.scopeInt2String(type);
    String strSQL="delete from "+PREFIX+"_"+strType+"_data where cfid=? and name=?";
    SQLImpl sql = new SQLImpl(strSQL,new SQLItem[]{
        new SQLItemImpl(cfid,Types.VARCHAR),
        new SQLItemImpl(applicationName,Types.VARCHAR)
      });
    execute(dc.getConnection(), sql,ThreadLocalPageContext.getTimeZone());
    ScopeContext.info(log,sql.toString());
   
  }
View Full Code Here

  public void clean(Config config, DatasourceConnection dc, int type,StorageScopeEngine engine,DatasourceStorageScopeCleaner cleaner,StorageScopeListener listener, Log log) throws PageException {
    String strType = VariableInterpreter.scopeInt2String(type);
    // select
      SQL sqlSelect=new SQLImpl("select cfid,name from "+PREFIX+"_"+strType+"_data where expires<=?"
            ,new SQLItem[]{
           new SQLItemImpl(System.currentTimeMillis(),Types.VARCHAR)
        });
      QueryImpl query;
      try{
        query = new QueryImpl(ThreadLocalPageContext.get(),dc,sqlSelect,-1,-1,-1,"query");
    }
    catch(Throwable t){
      // possible that the table not exist, if not there is nothing to clean
      return;
    }
   
    int recordcount=query.getRecordcount();
   
    String cfid,name;
    for(int row=1;row<=recordcount;row++){
      cfid=Caster.toString(query.getAt(KeyConstants._cfid, row, null),null);
      name=Caster.toString(query.getAt(KeyConstants._name, row, null),null);
     
      if(listener!=null)listener.doEnd(engine, cleaner,name, cfid);
     
     
      ScopeContext.info(log,"remove "+strType+"/"+name+"/"+cfid+" from datasource "+dc.getDatasource().getName());
      engine.remove(type,name,cfid);
      SQLImpl sql = new SQLImpl("delete from "+StorageScopeDatasource.PREFIX+"_"+strType+"_data where cfid=? and name=?",new SQLItem[]{
          new SQLItemImpl(cfid,Types.VARCHAR),
          new SQLItemImpl(name,Types.VARCHAR)
          });
      new QueryImpl(ThreadLocalPageContext.get(),dc,sql,-1,-1,-1,"query");
     
     
     
View Full Code Here

      ProcParamBean param;
      int index=1;
        while(it.hasNext()) {
          param= it.next();
          param.setIndex(index);
          _sql.addItems(new SQLItemImpl(param.getValue()));
          if(param.getDirection()!=ProcParamBean.DIRECTION_OUT) {
            SQLCaster.setValue(pageContext.getTimeZone(),callStat, index, param);
          }
          if(param.getDirection()!=ProcParamBean.DIRECTION_IN) {
            registerOutParameter(callStat,param);
View Full Code Here

  @Override
  public void release()  {
      separator=",";
      list=false;
      maxlength=-1;
      item=new SQLItemImpl();
  }
View Full Code Here

                    values.append(',');
                }
                names.append(field);
                values.append('?');
                ColumnInfo ci=(ColumnInfo) meta.get(field,null);
                if(ci!=null)items.add(new SQLItemImpl(form.get(field,null),ci.getType()));
                else items.add(new SQLItemImpl(form.get(field,null)));
            }
        }
        if(items.size()==0) return null;
       
        StringBuffer sql=new StringBuffer();
View Full Code Here

                  if(set.length()==0) set.append(" set ");
                  else set.append(",");
                  set.append(field);
                  set.append("=?");
                  ColumnInfo ci=(ColumnInfo) meta.get(field);
                  if(ci!=null)setItems.add(new SQLItemImpl(form.get(field,null),ci.getType()));
                  else setItems.add(new SQLItemImpl(form.get(field,null)));
                }
                else {
                  if(where.length()==0) where.append(" where ");
                  else where.append(" and ");
                  where.append(field);
                  where.append("=?");
                  whereItems.add(new SQLItemImpl(form.get(field,null)));
                }
            }
        }
        if((setItems.size()+whereItems.size())==0) return null;
       
View Full Code Here

TOP

Related Classes of railo.runtime.db.SQLItemImpl

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.