Search in sources :

Example 1 with SQLImpl

use of lucee.runtime.db.SQLImpl in project Lucee by lucee.

the class Query method doEndTag.

@Override
public int doEndTag() throws PageException {
    if (hasChangedPSQ)
        pageContext.setPsq(orgPSQ);
    String strSQL = bodyContent.getString().trim();
    if (strSQL.isEmpty())
        throw new DatabaseException("no sql string defined, inside query tag", null, null, null);
    try {
        // cannot use attribute params and queryparam tag
        if (!items.isEmpty() && 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 (params instanceof Argument)
                sql = QueryParamConverter.convert(strSQL, (Argument) params);
            else 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.isEmpty() ? new SQLImpl(strSQL) : new SQLImpl(strSQL, items.toArray(new SQLItem[items.size()]));
        }
        // lucee.runtime.type.Query query=null;
        QueryResult queryResult = null;
        String cacheHandlerId = null;
        String cacheId = null;
        long exe = 0;
        boolean useCache = (cachedWithin != null) || (cachedAfter != null);
        CacheHandler cacheHandler = null;
        if (useCache) {
            cacheId = CacheHandlerCollectionImpl.createId(sql, datasource != null ? datasource.getName() : null, username, password, returntype);
            CacheHandlerCollectionImpl coll = (CacheHandlerCollectionImpl) pageContext.getConfig().getCacheHandlerCollection(Config.CACHE_TYPE_QUERY, null);
            cacheHandler = coll.getInstanceMatchingObject(cachedWithin, null);
            if (cacheHandler == null && cachedAfter != null)
                cacheHandler = coll.getTimespanInstance(null);
            if (cacheHandler != null) {
                // cacheHandlerId specifies to queryResult the cacheType and therefore whether the query is cached or
                cacheHandlerId = cacheHandler.id();
                if (cacheHandler instanceof CacheHandlerPro) {
                    CacheItem cacheItem = ((CacheHandlerPro) cacheHandler).get(pageContext, cacheId, (cachedWithin != null) ? cachedWithin : cachedAfter);
                    if (cacheItem instanceof QueryResultCacheItem)
                        queryResult = ((QueryResultCacheItem) cacheItem).getQueryResult();
                } else {
                    // FUTURE this else block can be removed when all cache handlers implement CacheHandlerPro
                    CacheItem cacheItem = cacheHandler.get(pageContext, cacheId);
                    if (cacheItem instanceof QueryResultCacheItem) {
                        QueryResultCacheItem queryCachedItem = (QueryResultCacheItem) cacheItem;
                        Date cacheLimit = cachedAfter;
                        if (cacheLimit == null || queryCachedItem.isCachedAfter(cacheLimit))
                            queryResult = queryCachedItem.getQueryResult();
                    }
                }
            } else {
                List<String> patterns = pageContext.getConfig().getCacheHandlerCollection(Config.CACHE_TYPE_QUERY, null).getPatterns();
                throw new ApplicationException("cachedwithin value [" + cachedWithin + "] is invalid, valid values are for example [" + ListUtil.listToList(patterns, ", ") + "]");
            }
        // query=pageContext.getQueryCache().getQuery(pageContext,sql,datasource!=null?datasource.getName():null,username,password,cachedafter);
        }
        // cache not found, process and cache result if needed
        if (queryResult == null) {
            // QoQ
            if ("query".equals(dbtype)) {
                lucee.runtime.type.Query q = executeQoQ(sql);
                if (returntype == RETURN_TYPE_ARRAY)
                    // TODO this should be done in queryExecute itself so we not have to convert afterwards
                    queryResult = QueryArray.toQueryArray(q);
                else if (returntype == RETURN_TYPE_STRUCT) {
                    if (columnName == null)
                        throw new ApplicationException("attribute columnKey is required when return type is set to struct");
                    // TODO this should be done in queryExecute itself so we not have to convert
                    queryResult = QueryStruct.toQueryStruct(q, columnName);
                // afterwards
                } else
                    queryResult = (QueryResult) q;
            } else // ORM and Datasource
            {
                long start = System.nanoTime();
                Object obj;
                if ("orm".equals(dbtype) || "hql".equals(dbtype))
                    obj = executeORM(sql, returntype, ormoptions);
                else
                    obj = executeDatasoure(sql, result != null, pageContext.getTimeZone());
                if (obj instanceof QueryResult) {
                    queryResult = (QueryResult) obj;
                } else {
                    if (setReturnVariable) {
                        rtn = obj;
                    } else if (!StringUtil.isEmpty(name)) {
                        pageContext.setVariable(name, obj);
                    }
                    if (result != null) {
                        Struct sct = new StructImpl();
                        sct.setEL(KeyConstants._cached, Boolean.FALSE);
                        long time = System.nanoTime() - start;
                        sct.setEL(KeyConstants._executionTime, Caster.toDouble(time / 1000000));
                        sct.setEL(KeyConstants._executionTimeNano, Caster.toDouble(time));
                        sct.setEL(KeyConstants._SQL, sql.getSQLString());
                        if (Decision.isArray(obj)) {
                        } else
                            sct.setEL(KeyConstants._RECORDCOUNT, Caster.toDouble(1));
                        pageContext.setVariable(result, sct);
                    } else
                        setExecutionTime((System.nanoTime() - start) / 1000000);
                    return EVAL_PAGE;
                }
            }
            if (cachedWithin != null) {
                CacheItem cacheItem = QueryResultCacheItem.newInstance(queryResult, tags, datasource, null);
                if (cacheItem != null)
                    cacheHandler.set(pageContext, cacheId, cachedWithin, cacheItem);
            }
            exe = queryResult.getExecutionTime();
        } else {
            queryResult.setCacheType(cacheHandlerId);
        }
        if (pageContext.getConfig().debug() && debug) {
            boolean logdb = ((ConfigImpl) pageContext.getConfig()).hasDebugOptions(ConfigImpl.DEBUG_DATABASE);
            if (logdb) {
                boolean debugUsage = DebuggerImpl.debugQueryUsage(pageContext, queryResult);
                DebuggerImpl di = (DebuggerImpl) pageContext.getDebugger();
                di.addQuery(debugUsage ? queryResult : null, datasource != null ? datasource.getName() : null, name, sql, queryResult.getRecordcount(), getPageSource(), exe);
            }
        }
        if (setReturnVariable) {
            rtn = queryResult;
        } else if ((queryResult.getColumncount() + queryResult.getRecordcount()) > 0 && !StringUtil.isEmpty(name)) {
            pageContext.setVariable(name, queryResult);
        }
        // Result
        if (result != null) {
            Struct sct = new StructImpl();
            sct.setEL(KeyConstants._cached, Caster.toBoolean(queryResult.isCached()));
            if ((queryResult.getColumncount() + queryResult.getRecordcount()) > 0) {
                String list = ListUtil.arrayToList(queryResult instanceof lucee.runtime.type.Query ? ((lucee.runtime.type.Query) queryResult).getColumnNamesAsString() : CollectionUtil.toString(queryResult.getColumnNames(), false), ",");
                sct.setEL(KeyConstants._COLUMNLIST, list);
            }
            int rc = queryResult.getRecordcount();
            if (rc == 0)
                rc = queryResult.getUpdateCount();
            sct.setEL(KeyConstants._RECORDCOUNT, Caster.toDouble(rc));
            sct.setEL(KeyConstants._executionTime, Caster.toDouble(queryResult.getExecutionTime() / 1000000));
            sct.setEL(KeyConstants._executionTimeNano, Caster.toDouble(queryResult.getExecutionTime()));
            sct.setEL(KeyConstants._SQL, sql.getSQLString());
            // GENERATED KEYS
            lucee.runtime.type.Query qi = Caster.toQuery(queryResult, null);
            if (qi != null) {
                lucee.runtime.type.Query qryKeys = qi.getGeneratedKeys();
                if (qryKeys != null) {
                    StringBuilder generatedKey = new StringBuilder(), sb;
                    Collection.Key[] columnNames = qryKeys.getColumnNames();
                    QueryColumn column;
                    for (int c = 0; c < columnNames.length; c++) {
                        column = qryKeys.getColumn(columnNames[c]);
                        sb = new StringBuilder();
                        int size = column.size();
                        for (int row = 1; row <= size; row++) {
                            if (row > 1)
                                sb.append(',');
                            sb.append(Caster.toString(column.get(row, null)));
                        }
                        if (sb.length() > 0) {
                            sct.setEL(columnNames[c], sb.toString());
                            if (generatedKey.length() > 0)
                                generatedKey.append(',');
                            generatedKey.append(sb);
                        }
                    }
                    if (generatedKey.length() > 0)
                        sct.setEL(GENERATEDKEY, generatedKey.toString());
                }
            }
            // sqlparameters
            SQLItem[] params = sql.getItems();
            if (params != null && params.length > 0) {
                Array arr = new ArrayImpl();
                sct.setEL(SQL_PARAMETERS, arr);
                for (int i = 0; i < params.length; i++) {
                    arr.append(params[i].getValue());
                }
            }
            pageContext.setVariable(result, sct);
        } else // cfquery.executiontime
        {
            setExecutionTime(exe / 1000000);
        }
        // listener
        ((ConfigWebImpl) pageContext.getConfig()).getActionMonitorCollector().log(pageContext, "query", "Query", exe, queryResult);
        // log
        Log log = pageContext.getConfig().getLog("datasource");
        if (log.getLogLevel() >= Log.LEVEL_INFO) {
            log.info("query tag", "executed [" + sql.toString().trim() + "] in " + DecimalFormat.call(pageContext, exe / 1000000D) + " ms");
        }
    } catch (PageException pe) {
        // log
        pageContext.getConfig().getLog("datasource").error("query tag", pe);
        throw pe;
    } finally {
        ((PageContextImpl) pageContext).setTimestampWithTSOffset(previousLiteralTimestampWithTSOffset);
        if (tmpTZ != null) {
            pageContext.setTimeZone(tmpTZ);
        }
    }
    return EVAL_PAGE;
}
Also used : SQLImpl(lucee.runtime.db.SQLImpl) Argument(lucee.runtime.type.scope.Argument) SimpleQuery(lucee.runtime.type.query.SimpleQuery) ArrayImpl(lucee.runtime.type.ArrayImpl) DebuggerImpl(lucee.runtime.debug.DebuggerImpl) SQLItem(lucee.runtime.db.SQLItem) QueryStruct(lucee.runtime.type.query.QueryStruct) Struct(lucee.runtime.type.Struct) QueryResult(lucee.runtime.type.query.QueryResult) CacheHandlerPro(lucee.runtime.cache.tag.CacheHandlerPro) PageException(lucee.runtime.exp.PageException) Log(lucee.commons.io.log.Log) PageContextImpl(lucee.runtime.PageContextImpl) QueryResultCacheItem(lucee.runtime.cache.tag.query.QueryResultCacheItem) Date(java.util.Date) SQL(lucee.runtime.db.SQL) Array(lucee.runtime.type.Array) QueryArray(lucee.runtime.type.query.QueryArray) ApplicationException(lucee.runtime.exp.ApplicationException) StructImpl(lucee.runtime.type.StructImpl) QueryColumn(lucee.runtime.type.QueryColumn) CacheHandlerCollectionImpl(lucee.runtime.cache.tag.CacheHandlerCollectionImpl) QueryResultCacheItem(lucee.runtime.cache.tag.query.QueryResultCacheItem) CacheItem(lucee.runtime.cache.tag.CacheItem) CacheHandler(lucee.runtime.cache.tag.CacheHandler) DatabaseException(lucee.runtime.exp.DatabaseException) ConfigImpl(lucee.runtime.config.ConfigImpl) Key(lucee.runtime.type.Collection.Key)

Example 2 with SQLImpl

use of lucee.runtime.db.SQLImpl in project Lucee by lucee.

the class StoredProc method doEndTag.

@Override
public int doEndTag() throws PageException {
    long startNS = System.nanoTime();
    Object ds = datasource;
    if (StringUtil.isEmpty(datasource)) {
        ds = pageContext.getApplicationContext().getDefDataSource();
        if (StringUtil.isEmpty(ds)) {
            boolean isCFML = pageContext.getRequestDialect() == CFMLEngine.DIALECT_CFML;
            throw new ApplicationException("attribute [datasource] is required, when no default datasource is defined", "you can define a default datasource as attribute [defaultdatasource] of the tag " + (isCFML ? Constants.CFML_APPLICATION_TAG_NAME : Constants.LUCEE_APPLICATION_TAG_NAME) + " or as data member of the " + (isCFML ? Constants.CFML_APPLICATION_EVENT_HANDLER : Constants.LUCEE_APPLICATION_EVENT_HANDLER) + " (this.defaultdatasource=\"mydatasource\";)");
        }
    }
    Struct res = new StructImpl();
    DataSourceManager manager = pageContext.getDataSourceManager();
    DatasourceConnection dc = ds instanceof DataSource ? manager.getConnection(pageContext, (DataSource) ds, username, password) : manager.getConnection(pageContext, Caster.toString(ds), username, password);
    // create returnValue
    returnValue(dc);
    String sql = createSQL();
    // add returnValue to params
    if (returnValue != null) {
        params.add(0, returnValue);
    }
    Log log = pageContext.getConfig().getLog("datasource");
    SQLImpl _sql = new SQLImpl(sql);
    CallableStatement callStat = null;
    try {
        if (// log entry added to troubleshoot LDEV-1147
        log.getLogLevel() >= Log.LEVEL_DEBUG)
            log.debug("LDEV1147", sql + " [" + params.size() + " params]");
        callStat = dc.getConnection().prepareCall(sql);
        if (blockfactor > 0)
            callStat.setFetchSize(blockfactor);
        if (timeout > 0)
            DataSourceUtil.setQueryTimeoutSilent(callStat, timeout);
        // set IN register OUT
        Iterator<ProcParamBean> it = params.iterator();
        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, pageContext.getTimeZone(), callStat, index, param);
            }
            if (param.getDirection() != ProcParamBean.DIRECTION_IN) {
                registerOutParameter(callStat, param);
            }
            index++;
        }
        String dsn = (ds instanceof DataSource) ? ((DataSource) ds).getName() : Caster.toString(ds);
        // cache
        boolean isFromCache = false;
        Object cacheValue = null;
        boolean useCache = (cachedWithin != null) || (cachedafter != null);
        String cacheId = null;
        CacheHandler cacheHandler = null;
        if (useCache) {
            cacheId = CacheHandlerCollectionImpl.createId(_sql, dsn, username, password, Query.RETURN_TYPE_STORED_PROC);
            cacheHandler = pageContext.getConfig().getCacheHandlerCollection(Config.CACHE_TYPE_QUERY, null).getInstanceMatchingObject(cachedWithin, null);
            if (cacheHandler instanceof CacheHandlerPro) {
                CacheItem cacheItem = ((CacheHandlerPro) cacheHandler).get(pageContext, cacheId, cachedWithin);
                if (cacheItem != null)
                    cacheValue = ((StoredProcCacheItem) cacheItem).getStruct();
            } else if (cacheHandler != null) {
                // TODO this else block can be removed when all cache handlers implement CacheHandlerPro
                CacheItem cacheItem = cacheHandler.get(pageContext, cacheId);
                if (cacheItem != null)
                    cacheValue = ((StoredProcCacheItem) cacheItem).getStruct();
            // cacheValue = pageContext.getQueryCache().get(pageContext,_sql,dsn,username,password,cachedafter);
            }
        }
        int count = 0;
        long start = System.currentTimeMillis();
        if (cacheValue == null) {
            // execute
            boolean isResult = callStat.execute();
            Struct cacheStruct = useCache ? new StructImpl() : null;
            // resultsets
            ProcResultBean result;
            index = 1;
            do {
                if (isResult) {
                    ResultSet rs = callStat.getResultSet();
                    if (rs != null) {
                        try {
                            result = (ProcResultBean) results.get(index++, null);
                            if (result != null) {
                                lucee.runtime.type.Query q = new QueryImpl(rs, result.getMaxrows(), result.getName(), pageContext.getTimeZone());
                                count += q.getRecordcount();
                                setVariable(result.getName(), q);
                                if (useCache)
                                    cacheStruct.set(KeyImpl.getInstance(result.getName()), q);
                            }
                        } finally {
                            IOUtil.closeEL(rs);
                        }
                    }
                }
            } while ((isResult = callStat.getMoreResults()) || (callStat.getUpdateCount() != -1));
            // params
            it = params.iterator();
            while (it.hasNext()) {
                param = it.next();
                if (param.getDirection() != ProcParamBean.DIRECTION_IN) {
                    Object value = null;
                    if (!StringUtil.isEmpty(param.getVariable())) {
                        try {
                            value = SQLCaster.toCFType(callStat.getObject(param.getIndex()));
                        } catch (Throwable t) {
                            ExceptionUtil.rethrowIfNecessary(t);
                        }
                        value = emptyIfNull(value);
                        if (param == STATUS_CODE)
                            res.set(STATUSCODE, value);
                        else
                            setVariable(param.getVariable(), value);
                        if (useCache)
                            cacheStruct.set(KeyImpl.getInstance(param.getVariable()), value);
                    }
                }
            }
            if (cacheHandler != null) {
                cacheStruct.set(COUNT, Caster.toDouble(count));
                cacheHandler.set(pageContext, cacheId, cachedWithin, new StoredProcCacheItem(cacheStruct, procedure, System.currentTimeMillis() - start));
            // pageContext.getQueryCache().set(pageContext,_sql,dsn,username,password,cache,cachedbefore);
            }
        } else if (cacheValue instanceof Struct) {
            Struct sctCache = (Struct) cacheValue;
            count = Caster.toIntValue(sctCache.removeEL(COUNT), 0);
            Iterator<Entry<Key, Object>> cit = sctCache.entryIterator();
            Entry<Key, Object> ce;
            while (cit.hasNext()) {
                ce = cit.next();
                if (STATUS_CODE.getVariable().equals(ce.getKey().getString()))
                    res.set(KEY_SC, ce.getValue());
                else
                    setVariable(ce.getKey().getString(), ce.getValue());
            }
            isFromCache = true;
        }
        // result
        long exe;
        setVariable(this.result, res);
        res.set(KeyConstants._executionTime, Caster.toDouble(exe = (System.nanoTime() - startNS)));
        res.set(KeyConstants._cached, Caster.toBoolean(isFromCache));
        if (pageContext.getConfig().debug() && debug) {
            boolean logdb = ((ConfigImpl) pageContext.getConfig()).hasDebugOptions(ConfigImpl.DEBUG_DATABASE);
            if (logdb)
                pageContext.getDebugger().addQuery(null, dsn, procedure, _sql, count, pageContext.getCurrentPageSource(), (int) exe);
        }
        // log
        if (log.getLogLevel() >= Log.LEVEL_INFO) {
            log.info(StoredProc.class.getSimpleName(), "executed [" + sql.trim() + "] in " + DecimalFormat.call(pageContext, exe / 1000000D) + " ms");
        }
    } catch (SQLException e) {
        // log
        log.error(StoredProc.class.getSimpleName(), e);
        throw new DatabaseException(e, new SQLImpl(sql), dc);
    } catch (PageException pe) {
        // log
        log.error(StoredProc.class.getSimpleName(), pe);
        throw pe;
    } finally {
        if (callStat != null) {
            try {
                callStat.close();
            } catch (SQLException e) {
            }
        }
        manager.releaseConnection(pageContext, dc);
    }
    return EVAL_PAGE;
}
Also used : SQLImpl(lucee.runtime.db.SQLImpl) DatasourceConnection(lucee.runtime.db.DatasourceConnection) SQLException(java.sql.SQLException) DataSourceManager(lucee.runtime.db.DataSourceManager) Struct(lucee.runtime.type.Struct) StoredProcCacheItem(lucee.runtime.cache.tag.query.StoredProcCacheItem) QueryImpl(lucee.runtime.type.QueryImpl) Entry(java.util.Map.Entry) CallableStatement(java.sql.CallableStatement) CacheHandlerPro(lucee.runtime.cache.tag.CacheHandlerPro) ResultSet(java.sql.ResultSet) Iterator(java.util.Iterator) SQLItemImpl(lucee.runtime.db.SQLItemImpl) PageException(lucee.runtime.exp.PageException) Log(lucee.commons.io.log.Log) DataSource(lucee.runtime.db.DataSource) ApplicationException(lucee.runtime.exp.ApplicationException) StructImpl(lucee.runtime.type.StructImpl) CacheItem(lucee.runtime.cache.tag.CacheItem) StoredProcCacheItem(lucee.runtime.cache.tag.query.StoredProcCacheItem) CacheHandler(lucee.runtime.cache.tag.CacheHandler) DatabaseException(lucee.runtime.exp.DatabaseException) Key(lucee.runtime.type.Collection.Key) ConfigImpl(lucee.runtime.config.ConfigImpl)

Example 3 with SQLImpl

use of lucee.runtime.db.SQLImpl in project Lucee by lucee.

the class Update method createSQL.

/**
 * @param keys primary Keys
 * @return return SQL String for update
 * @throws PageException
 */
private SQL createSQL(DatasourceConnection dc, String[] keys, Struct meta) throws PageException {
    String[] fields = null;
    Form form = pageContext.formScope();
    if (formfields != null)
        fields = ListUtil.toStringArray(ListUtil.listToArrayRemoveEmpty(formfields, ','));
    else
        fields = CollectionUtil.keysAsString(pageContext.formScope());
    StringBuffer set = new StringBuffer();
    StringBuffer where = new StringBuffer();
    ArrayList setItems = new ArrayList();
    ArrayList whereItems = new ArrayList();
    String field;
    for (int i = 0; i < fields.length; i++) {
        field = StringUtil.trim(fields[i], null);
        if (StringUtil.startsWithIgnoreCase(field, "form."))
            field = field.substring(5);
        if (!field.equalsIgnoreCase("fieldnames")) {
            if (ArrayUtil.indexOfIgnoreCase(keys, field) == -1) {
                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;
    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);
        sql.append('.');
    }
    if (tableowner != null && tableowner.length() > 0) {
        sql.append(tableowner);
        sql.append('.');
    }
    sql.append(tablename);
    sql.append(set);
    sql.append(where);
    return new SQLImpl(sql.toString(), arrayMerge(setItems, whereItems));
}
Also used : SQLImpl(lucee.runtime.db.SQLImpl) Form(lucee.runtime.type.scope.Form) ArrayList(java.util.ArrayList) SQLItemImpl(lucee.runtime.db.SQLItemImpl) DatabaseException(lucee.runtime.exp.DatabaseException)

Example 4 with SQLImpl

use of lucee.runtime.db.SQLImpl in project Lucee by lucee.

the class Ansi92 method delete.

@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(null, dc.getConnection(), sql, ThreadLocalPageContext.getTimeZone());
    ScopeContext.info(log, sql.toString());
}
Also used : SQLImpl(lucee.runtime.db.SQLImpl) SQLItemImpl(lucee.runtime.db.SQLItemImpl)

Example 5 with SQLImpl

use of lucee.runtime.db.SQLImpl in project Lucee by lucee.

the class Ansi92 method _update.

private static int _update(Config config, Connection conn, String cfid, String applicationName, String strSQL, Object data, long timeSpan, Log log, TimeZone tz) throws SQLException, PageException {
    SQLImpl sql = new SQLImpl(strSQL, new SQLItem[] { new SQLItemImpl(createExpires(config, timeSpan), Types.VARCHAR), new SQLItemImpl(serialize(data, ignoreSet), Types.VARCHAR), new SQLItemImpl(cfid, Types.VARCHAR), new SQLItemImpl(applicationName, Types.VARCHAR) });
    ScopeContext.info(log, sql.toString());
    return execute(null, conn, sql, tz);
}
Also used : SQLImpl(lucee.runtime.db.SQLImpl) SQLItemImpl(lucee.runtime.db.SQLItemImpl)

Aggregations

SQLImpl (lucee.runtime.db.SQLImpl)8 SQLItemImpl (lucee.runtime.db.SQLItemImpl)7 DatabaseException (lucee.runtime.exp.DatabaseException)4 SQL (lucee.runtime.db.SQL)3 QueryImpl (lucee.runtime.type.QueryImpl)3 ArrayList (java.util.ArrayList)2 Log (lucee.commons.io.log.Log)2 CacheHandler (lucee.runtime.cache.tag.CacheHandler)2 CacheHandlerPro (lucee.runtime.cache.tag.CacheHandlerPro)2 CacheItem (lucee.runtime.cache.tag.CacheItem)2 ConfigImpl (lucee.runtime.config.ConfigImpl)2 SQLItem (lucee.runtime.db.SQLItem)2 ApplicationException (lucee.runtime.exp.ApplicationException)2 PageException (lucee.runtime.exp.PageException)2 Key (lucee.runtime.type.Collection.Key)2 Query (lucee.runtime.type.Query)2 Struct (lucee.runtime.type.Struct)2 StructImpl (lucee.runtime.type.StructImpl)2 CallableStatement (java.sql.CallableStatement)1 ResultSet (java.sql.ResultSet)1