use of lucee.runtime.db.DatasourceManagerImpl in project Lucee by lucee.
the class Query method executeDatasoure.
private QueryResult executeDatasoure(SQL sql, boolean createUpdateData, TimeZone tz) throws PageException {
DatasourceManagerImpl manager = (DatasourceManagerImpl) pageContext.getDataSourceManager();
DatasourceConnection dc = manager.getConnection(pageContext, datasource, username, password);
try {
if (lazy && !createUpdateData && cachedWithin == null && cachedAfter == null && result == null) {
if (returntype != RETURN_TYPE_QUERY)
throw new DatabaseException("only return type query is allowed when lazy is set to true", null, sql, dc);
return new SimpleQuery(pageContext, dc, sql, maxrows, blockfactor, timeout, getName(), getPageSource().getDisplayPath(), tz);
}
if (returntype == RETURN_TYPE_ARRAY)
return QueryImpl.toArray(pageContext, dc, sql, maxrows, blockfactor, timeout, getName(), getPageSource().getDisplayPath(), createUpdateData, true);
if (returntype == RETURN_TYPE_STRUCT) {
if (columnName == null)
throw new ApplicationException("attribute columnKey is required when return type is set to struct");
return QueryImpl.toStruct(pageContext, dc, sql, columnName, maxrows, blockfactor, timeout, getName(), getPageSource().getDisplayPath(), createUpdateData, true);
}
return new QueryImpl(pageContext, dc, sql, maxrows, blockfactor, timeout, getName(), getPageSource().getDisplayPath(), createUpdateData, true);
} finally {
manager.releaseConnection(pageContext, dc);
}
}
use of lucee.runtime.db.DatasourceManagerImpl in project Lucee by lucee.
the class Transaction method doStartTag.
@Override
public int doStartTag() throws PageException {
DataSourceManager manager = pageContext.getDataSourceManager();
// first transaction
if (manager.isAutoCommit()) {
// if(!hasBody)throw new DatabaseException("transaction tag with no end Tag can only be used inside a transaction tag",null,null,null);
manager.begin(isolation);
return EVAL_BODY_INCLUDE;
}
// inside transaction
innerTag = true;
switch(action) {
/* nested transaction no longer throw a exception, they are simply ignored
case ACTION_NONE:
throw new DatabaseException("you can't have a nested transaction with no action defined",null,null,null);
case ACTION_BEGIN:
throw new DatabaseException("you can't start a transaction inside a transaction tag",null,null,null);
*/
case ACTION_NONE:
case ACTION_BEGIN:
ignore = true;
break;
case ACTION_COMMIT:
manager.commit();
break;
case ACTION_ROLLBACK:
manager.rollback();
break;
case ACTION_SET_SAVEPOINT:
((DatasourceManagerImpl) manager).savepoint();
break;
}
return EVAL_BODY_INCLUDE;
}
use of lucee.runtime.db.DatasourceManagerImpl in project Lucee by lucee.
the class PageContextImpl method getORMSession.
@Override
public ORMSession getORMSession(boolean create) throws PageException {
if (ormSession == null || !ormSession.isValid()) {
if (!create)
return null;
ormSession = config.getORMEngine(this).createSession(this);
}
DatasourceManagerImpl manager = (DatasourceManagerImpl) getDataSourceManager();
manager.add(this, ormSession);
return ormSession;
}
use of lucee.runtime.db.DatasourceManagerImpl in project Lucee by lucee.
the class DBUtilImpl method releaseDatasourceConnection.
public void releaseDatasourceConnection(PageContext pc, DatasourceConnection dc, boolean managed) {
pc = ThreadLocalPageContext.get(pc);
if (managed) {
if (pc == null)
throw new PageRuntimeException(new ApplicationException("missing PageContext to access the Database Connection Manager"));
DatasourceManagerImpl manager = (DatasourceManagerImpl) pc.getDataSourceManager();
manager.releaseConnection(pc, dc);
return;
}
releaseDatasourceConnection(ThreadLocalPageContext.getConfig(pc), dc);
}
use of lucee.runtime.db.DatasourceManagerImpl in project Lucee by lucee.
the class DatasourceResourceProvider method getManager.
private DatasourceManagerImpl getManager() {
if (_manager == null) {
Config config = ThreadLocalPageContext.getConfig();
_manager = new DatasourceManagerImpl((ConfigImpl) config);
}
return _manager;
}
Aggregations