Search in sources :

Example 6 with DatasourceConnectionPool

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

the class DatasourceStorageScopeCleaner method clean.

private void clean(ConfigWeb config, DataSource dataSource) throws PageException, SQLException {
    ConfigWebImpl cwi = (ConfigWebImpl) config;
    DatasourceConnection dc = null;
    DatasourceConnectionPool pool = cwi.getDatasourceConnectionPool();
    try {
        dc = pool.getDatasourceConnection(null, dataSource, null, null);
        Log log = ((ConfigImpl) config).getLog("scope");
        SQLExecutor executor = SQLExecutionFactory.getInstance(dc);
        executor.clean(config, dc, type, engine, this, listener, log);
    } finally {
        if (dc != null)
            pool.releaseDatasourceConnection(dc);
    }
}
Also used : ConfigWebImpl(lucee.runtime.config.ConfigWebImpl) DatasourceConnection(lucee.runtime.db.DatasourceConnection) DatasourceConnectionPool(lucee.runtime.db.DatasourceConnectionPool) Log(lucee.commons.io.log.Log) SQLExecutor(lucee.runtime.type.scope.storage.db.SQLExecutor) ConfigImpl(lucee.runtime.config.ConfigImpl)

Example 7 with DatasourceConnectionPool

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

the class StorageScopeDatasource method store.

@Override
public void store(PageContext pc) {
    DatasourceConnection dc = null;
    ConfigImpl ci = (ConfigImpl) ThreadLocalPageContext.getConfig(pc);
    DatasourceConnectionPool pool = ci.getDatasourceConnectionPool();
    Log log = ci.getLog("scope");
    try {
        // FUTURE change method interface
        pc = ThreadLocalPageContext.get(pc);
        DataSource ds;
        if (pc != null)
            ds = pc.getDataSource(datasourceName);
        else
            ds = ci.getDataSource(datasourceName);
        dc = pool.getDatasourceConnection(null, ds, null, null);
        SQLExecutor executor = SQLExecutionFactory.getInstance(dc);
        executor.update(ci, cfid, appName, dc, getType(), sct, getTimeSpan(), log);
    } catch (Throwable t) {
        ExceptionUtil.rethrowIfNecessary(t);
        ScopeContext.error(log, t);
    } finally {
        if (dc != null)
            pool.releaseDatasourceConnection(dc);
    }
}
Also used : DatasourceConnection(lucee.runtime.db.DatasourceConnection) DatasourceConnectionPool(lucee.runtime.db.DatasourceConnectionPool) Log(lucee.commons.io.log.Log) SQLExecutor(lucee.runtime.type.scope.storage.db.SQLExecutor) ConfigImpl(lucee.runtime.config.ConfigImpl) DataSource(lucee.runtime.db.DataSource)

Example 8 with DatasourceConnectionPool

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

the class GetSystemInfo method getConnections.

public static int getConnections(ConfigWebImpl config) {
    int count = 0;
    DatasourceConnectionPool pool = config.getDatasourceConnectionPool();
    Iterator<Integer> it = pool.openConnections().values().iterator();
    Integer i;
    while (it.hasNext()) {
        i = it.next();
        if (i != null)
            count += i.intValue();
    }
    return count;
}
Also used : DatasourceConnectionPool(lucee.runtime.db.DatasourceConnectionPool)

Aggregations

DatasourceConnectionPool (lucee.runtime.db.DatasourceConnectionPool)8 ConfigImpl (lucee.runtime.config.ConfigImpl)7 DatasourceConnection (lucee.runtime.db.DatasourceConnection)7 SQLExecutor (lucee.runtime.type.scope.storage.db.SQLExecutor)7 DataSource (lucee.runtime.db.DataSource)4 Log (lucee.commons.io.log.Log)3 SQLException (java.sql.SQLException)2 ApplicationException (lucee.runtime.exp.ApplicationException)2 PageException (lucee.runtime.exp.PageException)2 Query (lucee.runtime.type.Query)2 ConfigWebImpl (lucee.runtime.config.ConfigWebImpl)1 Struct (lucee.runtime.type.Struct)1